:root {
    /* Khatabook-like Palette */
    --primary: #c60000;
    /* Red - YOU GAVE (Main Action) */
    --primary-dark: #8e0000;
    --primary-light: #fad4d4;

    --payment: #008744;
    /* Green - YOU GOT */
    --payment-dark: #005c2f;
    --payment-light: #d4fadd;

    --secondary: #64748b;
    --danger: #c60000;
    --danger-light: #fad4d4;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px;
    /* Space for FAB/Nav */
}

/* Header */
header {
    background: var(--bg-card);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--text-muted);
}

.container {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

/* Dashboard Cards */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
}

.card.full-width {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.card.full-width h3 {
    color: rgba(255, 255, 255, 0.9);
}

.card.full-width .amount {
    color: white;
}

.card h3 {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.card .amount {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
}

.card .trend {
    font-size: 0.8rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend.up {
    color: var(--primary);
}

.trend.down {
    color: var(--danger);
}

/* Tabs Removed */

/* List Items */
.list-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.1s;
}

.list-item:active {
    transform: scale(0.98);
}

.list-info h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
}

.list-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.list-amount {
    text-align: right;
    font-weight: 700;
    font-size: 1.1rem;
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--primary);
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    z-index: 200;
}

.fab:hover {
    transform: translateY(-2px);
    background: var(--primary-dark);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-end;
    /* Bottom sheet on mobile */
    justify-content: center;
    z-index: 200000;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-content {
    transform: translateY(0);
}

@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius);
        transform: translateY(20px);
    }

    .modal-overlay.open .modal-content {
        transform: translateY(0);
    }
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-block {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* Util */
.hidden {
    display: none !important;
}

/* New Party List Grid Layout */
.party-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px; /* Reduced gap */
    align-items: center;
    background: white;
    padding: 10px 12px; /* Compact Padding (was 15px) */
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}

.party-item:active {
    background: #f1f5f9;
}

/* Left Column: Avatar + Details */
.party-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    /* For text wrapping context */
}

.party-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #64748b;
    font-size: 1.1em;
    flex-shrink: 0;
}

.party-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* Critical for flex child text truncation/wrapping */
}

.party-name {
    font-weight: 600;
    font-size: 1rem;
    color: #1e293b;
    word-break: break-word;
    /* User Req #2 */
    line-height: 1.3;
}

.party-meta {
    font-size: 0.8em;
    color: #94a3b8;
    margin-top: 3px;
    line-height: 1.2;
}

/* Right Column: Amount */
.party-amount-col {
    text-align: right;
    min-width: fit-content;
    white-space: nowrap;
    /* Keep currency and amount together */
}

.party-amount {
    font-weight: 800;
    /* User Req #3 */
    font-size: 1.15rem;
    /* Larger font */
}

.party-label {
    font-size: 0.75em;
    font-weight: 500;
    margin-top: 2px;
}