/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8fafc; --bg-card: #ffffff; --bg-muted: #f1f5f9; --bg-hover: #e2e8f0;
  --text: #0f172a; --text-muted: #475569; --text-light: #94a3b8;
  --primary: #6366f1; --primary-light: #818cf8; --primary-dark: #4f46e5;
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #10b981; --success-bg: #d1fae5;
  --warning: #f59e0b; --warning-bg: #fef3c7;
  --danger: #ef4444; --danger-bg: #fee2e2;
  --info: #3b82f6; --info-bg: #dbeafe;
  --border: #e2e8f0; --border-dark: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 50px -10px rgba(0,0,0,0.12);
  --radius: 12px; --radius-sm: 8px; --radius-lg: 16px; --radius-full: 9999px;
  --font: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* ===== NAVBAR ===== */
.navbar { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 0 24px; position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px); background: rgba(255,255,255,0.9); }
.navbar-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 64px; }
.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: var(--text); }
.brand-icon { font-size: 1.5rem; }
.navbar-actions { display: flex; align-items: center; gap: 16px; }
.user-greeting { font-size: 0.875rem; color: var(--text-muted); }

/* ===== MAIN CONTENT ===== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border: none; border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all var(--transition); line-height: 1.4; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(99,102,241,0.45); color: #fff; }
.btn-secondary { background: var(--bg-muted); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 8px 14px; }
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }

/* ===== CARDS ===== */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); transition: all var(--transition); }
.card:hover { box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.9rem; color: var(--text); background: var(--bg-card); transition: border-color var(--transition), box-shadow var(--transition); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.input-group { display: flex; gap: 0; }
.input-group .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-select { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; max-width: 100px; }
.amount-input { font-family: var(--font-mono); font-weight: 600; font-size: 1.1rem; }

/* ===== CHECKBOX GROUP ===== */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-chip { position: relative; }
.checkbox-chip input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-chip label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-full); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all var(--transition); user-select: none; color: var(--text-muted); }
.checkbox-chip input:checked + label { background: rgba(99,102,241,0.1); border-color: var(--primary); color: var(--primary); }
.checkbox-chip label:hover { border-color: var(--primary-light); background: var(--bg-muted); }
.select-all-btn { font-size: 0.78rem; color: var(--primary); cursor: pointer; font-weight: 600; background: none; border: none; padding: 4px 8px; }

/* ===== MODAL ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.4); backdrop-filter: blur(4px); z-index: 200; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
.modal-backdrop.active { opacity: 1; visibility: visible; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95); z-index: 201; background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; opacity: 0; visibility: hidden; transition: all 0.3s cubic-bezier(0.4,0,0.2,1); }
.modal.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-close { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: none; background: var(--bg-muted); border-radius: var(--radius-sm); cursor: pointer; font-size: 1.2rem; color: var(--text-muted); transition: all var(--transition); }
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 28px; overflow-x: auto; padding-bottom: 0; }
.tab-btn { padding: 12px 20px; border: none; background: none; font-family: var(--font); font-size: 0.9rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition); white-space: nowrap; }
.tab-btn:hover { color: var(--text); background: var(--bg-muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); background: var(--bg-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 14px 16px; font-size: 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-muted); }
.amount-cell { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }
.currency-badge { display: inline-flex; padding: 2px 8px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 700; margin-right: 4px; }
.currency-TRY { background: #dbeafe; color: #1d4ed8; }
.currency-USD { background: #d1fae5; color: #047857; }
.currency-EUR { background: #fef3c7; color: #b45309; }
.action-btns { display: flex; gap: 6px; justify-content: flex-end; align-items: center; height: 100%; }

/* ===== GRID LAYOUTS ===== */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }

/* ===== PLAN CARD ===== */
.plan-card { cursor: pointer; position: relative; overflow: hidden; }
.plan-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--gradient); }
.plan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.plan-card .plan-name { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.plan-card .plan-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.plan-card .plan-meta { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-light); }
.plan-card .plan-meta span { display: flex; align-items: center; gap: 4px; }
.plan-status { display: inline-flex; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.plan-status.active { background: var(--success-bg); color: var(--success); }
.plan-status.settled { background: var(--bg-muted); color: var(--text-light); }

/* ===== STAT CARD ===== */
.stat-card { text-align: center; padding: 20px; }
.stat-value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ===== SETTLEMENT ===== */
.settlement-list { display: flex; flex-direction: column; gap: 12px; }
.settlement-item { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--bg-muted); border-radius: var(--radius); border-left: 4px solid var(--primary); }
.settlement-arrow { font-size: 1.3rem; color: var(--primary); }
.settlement-amount { font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; color: var(--primary-dark); margin-left: auto; }
.settlement-from, .settlement-to { font-weight: 600; }

/* ===== BALANCE BAR ===== */
.balance-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.balance-item { display: flex; align-items: center; gap: 12px; }
.balance-name { width: 120px; font-weight: 600; font-size: 0.9rem; text-align: right; flex-shrink: 0; }
.balance-bar-wrap { flex: 1; height: 28px; background: var(--bg-muted); border-radius: var(--radius-full); overflow: hidden; position: relative; }
.balance-bar { height: 100%; border-radius: var(--radius-full); transition: width 0.6s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; }
.balance-bar.positive { background: linear-gradient(90deg, #34d399, #10b981); }
.balance-bar.negative { background: linear-gradient(90deg, #f87171, #ef4444); }
.balance-value { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; color: #fff; white-space: nowrap; }

/* ===== MEMBER CHIPS ===== */
.member-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.member-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; background: var(--bg-muted); border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.member-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ===== AUTH PAGE ===== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 50%, #f0fdf4 100%); padding: 24px; }
.auth-container { width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .brand-icon { font-size: 3rem; display: block; margin-bottom: 8px; }
.auth-logo h1 { font-size: 1.8rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.auth-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.auth-card { background: var(--bg-card); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-tabs { display: flex; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.auth-tab { flex: 1; padding: 12px; text-align: center; border: none; background: none; font-family: var(--font); font-size: 0.9rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition); }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-divider { text-align: center; margin: 24px 0; position: relative; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { background: var(--bg-card); padding: 0 16px; position: relative; color: var(--text-light); font-size: 0.85rem; }
.guest-link { text-align: center; margin-top: 20px; }
.guest-link a { font-size: 0.85rem; font-weight: 600; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 16px; }
.page-title { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.page-subtitle { font-size: 0.9rem; color: var(--text-muted); margin-top: 2px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 14px 20px; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: slideInRight 0.35s ease, fadeOut 0.35s ease 2.65s forwards; min-width: 280px; display: flex; align-items: center; gap: 10px; }
.toast-success { background: #065f46; color: #d1fae5; }
.toast-error { background: #991b1b; color: #fee2e2; }
.toast-info { background: #1e3a5f; color: #dbeafe; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(30px); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-content { padding: 20px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .plan-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .tabs { gap: 0; }
  .tab-btn { padding: 10px 14px; font-size: 0.82rem; }
  .modal { width: 95%; max-height: 95vh; }
  .navbar-inner { padding: 0; }
  .user-greeting { display: none; }
  .settlement-item { flex-wrap: wrap; }
  .balance-name { width: 80px; font-size: 0.8rem; }
  .table-wrapper { font-size: 0.85rem; }
  th, td { padding: 10px 12px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 20px; }
}
