:root {
--bg: #f8fafc;
--bg-gradient-1: #f8fafc;
--bg-gradient-2: #e2e8f0;
--card: #ffffff;
--card-soft: #f8fafc;
--text: #0f172a;
--muted: #475569;
--input-bg: #ffffff;
--input-text: #0f172a;
--border: #cbd5e1;
--primary: #2563eb;
--secondary: #e2e8f0;
--secondary-text: #0f172a;
--danger: #dc2626;
--success: #16a34a;
--summary-bg: #e2e8f0;
--shadow: 0 10px 25px rgba(0,0,0,0.08);
}

body.dark-mode {
--bg: #0f172a;
--bg-gradient-1: #1e293b;
--bg-gradient-2: #0f172a;
--card: #1e293b;
--card-soft: #162235;
--text: #f1f5f9;
--muted: #cbd5e1;
--input-bg: #0f172a;
--input-text: #ffffff;
--border: rgba(255,255,255,0.08);
--primary: #2563eb;
--secondary: #334155;
--secondary-text: #ffffff;
--danger: #dc2626;
--success: #16a34a;
--summary-bg: #020617;
--shadow: 0 10px 25px rgba(0,0,0,0.35);
}

body {
margin: 0;
font-family: Arial, sans-serif;
background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
color: var(--text);
transition: background 0.25s ease, color 0.25s ease;
}

.app-shell {
padding: 20px;
max-width: 1280px;
margin: 0 auto;
}

.main-grid {
display: grid;
gap: 20px;
}

.card {
background: var(--card);
padding: 20px;
border-radius: 14px;
box-shadow: var(--shadow);
transition: background 0.25s ease, color 0.25s ease;
}

.inner-card {
background: var(--card-soft);
border: 1px solid var(--border);
}

.topbar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
margin-bottom: 25px;
}

.brand-wrap {
display: flex;
align-items: center;
gap: 12px;
}

.brand-logo {
height: 44px;
width: auto;
border-radius: 10px;
}

h1, h2, h3 {
margin: 0 0 8px 0;
}

.subtitle {
margin: 0;
color: var(--muted);
}

.top-actions,
.actions-row,
.section-head,
.actions {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}

.section-head {
justify-content: space-between;
}

.section-head.compact {
margin-bottom: 8px;
}

button {
border: none;
padding: 10px 16px;
border-radius: 10px;
cursor: pointer;
font-weight: bold;
transition: 0.2s ease;
}

button:not(.secondary-btn):not(.danger-btn):not(.green-btn) {
background: var(--primary);
color: white;
}

button:hover {
opacity: 0.92;
}

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

.danger-btn {
background: var(--danger);
color: white;
}

.green-btn {
background: var(--success);
color: white;
}

.small-btn {
padding: 8px 12px;
font-size: 13px;
margin-top: 0;
}

input,
select {
width: 100%;
padding: 10px 12px;
border-radius: 8px;
border: 1px solid var(--border);
margin-bottom: 10px;
background: var(--input-bg);
color: var(--input-text);
box-sizing: border-box;
}

label {
display: block;
margin: 12px 0 6px;
font-weight: 700;
}

.form-grid,
.two-col,
.stats-grid {
display: grid;
gap: 16px;
}

.form-grid {
grid-template-columns: 1fr 1fr 1fr;
}

.two-col {
grid-template-columns: 1fr 1fr;
margin-top: 20px;
}

.stats-grid {
grid-template-columns: repeat(3, 1fr);
margin-bottom: 15px;
}

.stat-card {
background: var(--card-soft);
padding: 15px;
border-radius: 10px;
text-align: center;
border: 1px solid var(--border);
}

.stat-label {
opacity: 0.75;
}

.stat-value {
font-size: 20px;
font-weight: bold;
}

.summary-box {
background: var(--summary-bg);
border-radius: 12px;
padding: 15px;
margin-bottom: 15px;
text-align: center;
font-size: 18px;
font-weight: bold;
}

.summary-positive {
color: #22c55e;
}

.summary-negative {
color: #ef4444;
}

.member-row,
.balance-row,
.expense-row,
.settlement-row,
.group-row,
.settled-row {
background: var(--card-soft);
padding: 12px;
border-radius: 10px;
margin-bottom: 10px;
display: flex;
justify-content: space-between;
gap: 12px;
align-items: flex-start;
border: 1px solid var(--border);
}

.highlight-me {
border: 2px solid var(--primary);
}

.amount-positive {
color: #22c55e;
font-weight: bold;
}

.amount-negative {
color: #ef4444;
font-weight: bold;
}

.expense-title,
.group-title {
font-weight: 800;
margin-bottom: 4px;
}

.empty,
.subline {
color: var(--muted);
}

.badge {
padding: 10px 14px;
border-radius: 999px;
font-size: 13px;
font-weight: 700;
}

.muted-badge {
background: #94a3b8;
color: white;
}

.green-badge {
background: #166534;
color: white;
}

.toast {
position: fixed;
bottom: 90px;
right: 20px;
background: var(--summary-bg);
color: var(--text);
padding: 12px 16px;
border-radius: 10px;
z-index: 999;
box-shadow: var(--shadow);
}

.fab {
position: fixed;
bottom: 20px;
right: 20px;
background: var(--primary);
color: white;
border-radius: 50%;
width: 60px;
height: 60px;
font-size: 28px;
box-shadow: var(--shadow);
}

.hidden {
display: none !important;
}

@media (max-width: 960px) {
.topbar,
.section-head {
flex-direction: column;
align-items: stretch;
}

.form-grid,
.two-col,
.stats-grid {
grid-template-columns: 1fr;
}
}
