:root {
    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    /* Pink 500 */
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 16px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Prevent body horizontal scroll */
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    gap: 1rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    background: -webkit-linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

/* Nav Links */
.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-links a.btn-sm {
    white-space: nowrap;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    width: 100%;
    /* Ensure card fits container */
}

/* Grid Layouts - Fixed for Mobile */
.grid-3 {
    display: grid;
    /* Reduced min-width to 280px to fit smaller phones (like iPhone SE) without overflow */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Typography & Colors */
.bg-gradient-primary {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
}

.bg-gradient-primary h3,
.bg-gradient-primary p {
    color: rgba(255, 255, 255, 0.9);
}

.bg-gradient-primary .amount {
    color: white;
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.amount {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    word-break: break-all;
}

/* Break long numbers */

/* Partners */
.member-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.member-name {
    font-size: 1.25rem;
    font-weight: 700;
}

.invested-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    margin-bottom: 1rem;
}

.balance-box {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    word-break: break-word;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-star {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.badge-neutral {
    background: #f3f4f6;
    color: #4b5563;
}

/* Table Wrapper for Mobile Scrolling */
.table-wrapper {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    width: 100%;
    /* KEY FIX: Allows horizontal scroll if table is wide */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Force scroll on small screens */
}

th {
    background: #f9fafb;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    padding: 1rem;
    text-align: left;
}

td {
    padding: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.9rem;
}

/* Inputs & Buttons */
.form-group {
    margin-bottom: 1.5rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    background: #f9fafb;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Login Page Only */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    max-width: 400px;
    margin: 0 auto;
}

/* Utilities */
.text-success {
    color: var(--success);
}

.text-danger {
    color: #ef4444;
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    .amount {
        font-size: 1.75rem;
    }

    .card {
        padding: 1.25rem;
    }
}