:root {
    /* Curated HSL Tailored Color Tokens */
    --primary-h: 250;
    --primary-s: 95%;
    --primary-l: 60%;
    
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) - 8%));
    --primary-light: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.08);
    --primary-glow: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.18);
    
    --secondary: #64748b;
    --secondary-hover: #475569;
    
    --danger: #f43f5e;
    --danger-hover: #e11d48;
    --warning: #d97706;
    
    --green: #10b981;
    --red: #f43f5e;
    
    --bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text: #0f172a;
    --text-color: var(--text);
    --border: rgba(203, 213, 225, 0.6);
    
    --radius: 12px;
    --radius-md: 10px;
    --radius-sm: 8px;
    
    /* Premium Soft Shadows */
    --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.04), 0 4px 10px -4px rgba(15, 23, 42, 0.02);
    --shadow-lg: 0 15px 30px -8px rgba(15, 23, 42, 0.08);
    --shadow-focus: 0 0 0 3px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.15);
}

html { 
    scroll-behavior: smooth; 
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(ellipse at top left, #f8fafc 0%, #cbd5e1 100%);
    background-attachment: fixed;
    color: var(--text);
    margin: 0;
    padding: 8px 12px;
    line-height: 1.4;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none; /* Prevents mobile pull-to-refresh */
}

/* Typography Hierarchy */
h1, h2, h3, .trip-name-input, .expense-amount, .global-stat-value, .stat-name, .mini-calc-header-title {
    font-family: 'Outfit', sans-serif;
}

.tabular-nums { 
    font-variant-numeric: tabular-nums; 
}

.app-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
}

/* TOP BAR AREA */
.top-bar-area {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
    position: relative;
}

#header-toggle-btn {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--secondary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    padding: 3px 6px;
    flex: none;
    display: inline-block;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border);
}
#header-toggle-btn:hover {
    color: var(--primary);
    background: #ffffff;
}

/* HEADER COLLAPSE STYLES */
.header-collapsed .header-collapsible-item { 
    display: none !important; 
}

.mobile-quick-nav { 
    display: flex; 
    gap: 6px; 
    justify-content: center; 
    flex-wrap: wrap; 
    margin-bottom: 6px; 
}

details.participants-dropdown {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

details.participants-dropdown summary {
    font-weight: 700; 
    font-size: 0.9rem; 
    color: var(--primary); 
    cursor: pointer; 
    list-style: none;
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    user-select: none;
}
details.participants-dropdown summary::-webkit-details-marker { 
    display: none; 
}
details.participants-dropdown summary::after { 
    content: '▼'; 
    font-size: 0.75rem; 
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
details.participants-dropdown[open] summary::after { 
    transform: rotate(180deg); 
}
details.participants-dropdown[open] { 
    padding-bottom: 12px; 
    box-shadow: var(--shadow-md);
}

.header-top-row { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    align-items: stretch; 
}

@media (min-width: 1024px) {
    body { 
        height: 100vh; 
        overflow: hidden; 
        display: flex; 
        flex-direction: column; 
        padding-bottom: 0; 
    }
    .mobile-quick-nav { 
        display: none !important; 
    }
    .header-top-row { 
        flex-direction: row; 
        justify-content: space-between; 
        align-items: center; 
    }
    
    .app-container { 
        grid-template-columns: 370px 1fr; 
        grid-template-rows: auto 1fr; 
        flex: 1; 
        min-height: 0; 
        overflow-y: auto; 
        overflow-x: hidden; 
        gap: 16px; 
        padding-right: 4px;
    }
    .col-right { 
        grid-column: 1 / -1; 
    }
    
    .col-left, .col-mid, .col-right {
        height: 100%; 
        overflow-y: auto; 
        padding-right: 8px; 
        padding-bottom: 20px; 
        scrollbar-width: thin; 
        scrollbar-color: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.2) transparent;
    }
    .col-left::-webkit-scrollbar, .col-mid::-webkit-scrollbar, .col-right::-webkit-scrollbar { 
        width: 5px; 
    }
    .col-left::-webkit-scrollbar-track, .col-mid::-webkit-scrollbar-track, .col-right::-webkit-scrollbar-track { 
        background: transparent; 
    }
    .col-left::-webkit-scrollbar-thumb, .col-mid::-webkit-scrollbar-thumb, .col-right::-webkit-scrollbar-thumb { 
        background: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.2); 
        border-radius: 4px; 
        transition: background 0.3s;
    }
    .col-left::-webkit-scrollbar-thumb:hover, .col-mid::-webkit-scrollbar-thumb:hover, .col-right::-webkit-scrollbar-thumb:hover {
        background: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.4); 
    }
    .trip-name-input { 
        text-align: left; 
        margin-bottom: 0; 
        width: auto; 
    }
    .trip-comment-input { 
        text-align: left; 
        margin: 0; 
    }
}

@media (min-width: 1180px) {
    .app-container { 
        grid-template-columns: 370px 1fr 1fr; 
        overflow: hidden; 
        padding-right: 0;
    }
    .col-left { grid-column: 1; }
    .col-mid { grid-column: 2; }
    .col-right { grid-column: 3; }
}

.glass-toolbar {
    display: flex; 
    gap: 6px; 
    flex-wrap: wrap; 
    justify-content: center; 
    align-items: center;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.trip-name-input {
    font-size: 1.35rem; 
    font-weight: 900; 
    color: var(--text); 
    letter-spacing: -0.02em;
    text-align: center; 
    border: 2px dashed transparent; 
    background: transparent;
    padding: 2px 6px; 
    box-sizing: border-box; 
    transition: all 0.25s ease; 
    border-radius: var(--radius-sm);
    width: 100%;
}
.trip-name-input:focus, .trip-name-input:hover { 
    border-color: var(--primary); 
    outline: none; 
    background: rgba(255, 255, 255, 0.8); 
    color: var(--primary); 
}

.trip-comment-input {
    font-size: 0.82rem; 
    font-weight: 500; 
    color: var(--secondary);
    text-align: center; 
    border: 1px dashed transparent; 
    background: transparent;
    padding: 2px 6px; 
    box-sizing: border-box; 
    transition: all 0.25s ease; 
    border-radius: var(--radius-sm);
    width: 100%; 
    max-width: 300px;
}
.trip-comment-input:focus, .trip-comment-input:hover { 
    border-color: var(--border); 
    outline: none; 
    background: rgba(255, 255, 255, 0.8); 
    color: var(--text); 
}

.next-payer-badge {
    background: #fff1f2; 
    border: 1px solid #fecdd3; 
    color: #be123c;
    padding: 4px 8px; 
    border-radius: 8px; 
    font-size: 0.78rem; 
    font-weight: 700;
    display: flex; 
    align-items: center; 
    gap: 4px; 
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.cloud-slot {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 2px;
    background: rgba(255, 255, 255, 0.5); 
    padding: 4px; 
    border-radius: var(--radius-sm); 
    border: 1px solid var(--border);
    min-width: 0;
}
.cloud-slot.auto-backup { 
    background: rgba(224, 242, 254, 0.6); 
    border-color: #bae6fd; 
}
.cloud-slot .slot-label { 
    font-size: 0.6rem; 
    font-weight: 800; 
    color: var(--secondary); 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
}
.cloud-slot.auto-backup .slot-label { 
    color: #0369a1; 
}
.cloud-slot .slot-btns { 
    display: flex; 
    gap: 2px; 
    width: 100%; 
}
.cloud-slot .slot-btns button { 
    flex: 1; 
    padding: 2px 0; 
    font-size: 0.65rem; 
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); 
}
.cloud-slot .slot-name { 
    font-size: 0.65rem; 
    font-weight: 700; 
    color: var(--primary); 
    text-align: center; 
    margin-top: auto; 
    overflow: hidden; 
    white-space: nowrap; 
    text-overflow: ellipsis; 
    max-width: 100%; 
    width: 100%; 
}
.cloud-slot.auto-backup .slot-name { 
    color: #0369a1; 
}

@keyframes pulse-warning {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
.btn-update-available {
    background-color: #f59e0b !important; 
    color: white !important;
    animation: pulse-warning 2s infinite;
    border: 1px solid #d97706 !important;
}

/* Compact Glassmorphism Card Layout */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius); 
    padding: 12px 14px; 
    margin-bottom: 12px;
    box-shadow: var(--shadow-md);
    position: relative;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.card:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 12px 24px -8px rgba(15, 23, 42, 0.06);
}

.corner-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--secondary);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    padding: 2px;
    line-height: 1;
    z-index: 10;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.corner-toggle:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.9);
}

.card.edit-mode {
    box-shadow: 0 6px 20px -4px rgba(79, 70, 229, 0.15);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.9);
}

#activity-card {
    display: flex; 
    flex-direction: column;
    max-height: calc(100vh - 100px); 
    position: relative;
}

.activity-collapsed #activity-content-wrapper { 
    display: none !important; 
}
.activity-collapsed #activity-toggle-icon { 
    transform: rotate(180deg); 
}

.activity-form-scrollable { 
    overflow-y: auto; 
    padding-right: 4px; 
    padding-bottom: 6px; 
    scrollbar-width: thin; 
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent; 
}
.activity-form-scrollable::-webkit-scrollbar { 
    width: 3px; 
}
.activity-form-scrollable::-webkit-scrollbar-thumb { 
    background: rgba(0, 0, 0, 0.15); 
    border-radius: 3px; 
}

.sticky-action-buttons {
    position: sticky; 
    bottom: -14px; 
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 14px; 
    margin: 0 -14px -14px -14px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    z-index: 10;
}

h2 { 
    margin: 0 0 8px 0; 
    font-size: 1.05rem; 
    font-weight: 800; 
    color: #0f172a; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 6px;
}

.form-row { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 8px; 
}

input, select { 
    width: 100%; 
    padding: 6px 10px; 
    background: rgba(255, 255, 255, 0.7); 
    border: 1px solid rgba(203, 213, 225, 0.8); 
    border-radius: var(--radius-sm); 
    font-size: 0.85rem; 
    font-family: inherit; 
    font-weight: 500; 
    color: var(--text);
    box-sizing: border-box; 
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); 
}
input:focus, select:focus { 
    background: #ffffff; 
    border-color: var(--primary); 
    outline: none; 
    box-shadow: var(--shadow-focus); 
}

.amount-currency-group { 
    display: flex; 
    align-items: stretch; 
    width: 100%; 
}
.amount-currency-group input:first-child { 
    border-radius: var(--radius-sm) 0 0 var(--radius-sm); 
    border-right: 1px solid var(--border); 
    flex: 1; 
    min-width: 0;
}
.amount-currency-group select { cursor: pointer; 
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0; 
    border-left: none; 
    background: #f1f5f9; 
    color: var(--secondary); 
    font-weight: 800; 
    padding: 0 8px; 
    width: auto; 
    flex: none; 
}

/* Premium Button Designs - Compact */
button {
    background: linear-gradient(135deg, hsl(var(--primary-h), var(--primary-s), var(--primary-l)), hsl(calc(var(--primary-h) + 10), var(--primary-s), calc(var(--primary-l) - 5%)));
    color: white; 
    border: none; 
    padding: 6px 12px;
    border-radius: var(--radius-sm); 
    font-size: 0.85rem; 
    font-family: inherit; 
    cursor: pointer; 
    font-weight: 600;
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 4px; 
    flex: 1; 
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
button:hover { 
    background: linear-gradient(135deg, hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) + 5%)), hsl(calc(var(--primary-h) + 10), var(--primary-s), var(--primary-l)));
    transform: translateY(-1px); 
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
button:active { 
    transform: translateY(0); 
}

button.secondary { 
    background: linear-gradient(135deg, #64748b, #475569); 
    box-shadow: 0 2px 6px rgba(100, 116, 139, 0.15);
}
button.secondary:hover { 
    background: linear-gradient(135deg, #78889b, #576579);
    box-shadow: 0 4px 10px rgba(100, 116, 139, 0.25);
}
button.danger { 
    background: linear-gradient(135deg, #f43f5e, #be123c); 
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.15);
}
button.danger:hover { 
    background: linear-gradient(135deg, #ff4d73, #d11a43);
    box-shadow: 0 4px 10px rgba(244, 63, 94, 0.25);
}
button.warning { 
    background: linear-gradient(135deg, #f59e0b, #d97706); 
    color: white;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}
button.warning:hover { 
    background: linear-gradient(135deg, #fbbf24, #ea580c);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25);
}
button.cloud { 
    background: linear-gradient(135deg, #0ea5e9, #0284c7); 
    color: white;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.15);
}
button.cloud:hover { 
    background: linear-gradient(135deg, #38bdf8, #0369a1);
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.25);
}

button.small { 
    padding: 4px 8px; 
    font-size: 0.8rem; 
    flex: none; 
    box-shadow: none;
}
button.outline { 
    background: rgba(255, 255, 255, 0.6); 
    color: var(--secondary); 
    border: 1px solid var(--border); 
    box-shadow: var(--shadow-sm);
}
button.outline:hover { 
    background: #ffffff; 
    color: var(--primary); 
    border-color: var(--primary);
}

.flex-1 { 
    flex: 1; 
}

/* Tag badge redesign - Compact */
.tag {
    display: inline-flex; 
    align-items: center; 
    padding: 3px 8px; 
    border-radius: 16px; 
    margin: 2px; 
    font-weight: 700; 
    gap: 6px;
    box-shadow: var(--shadow-sm); 
    font-size: 0.78rem; 
    border: 1px solid rgba(255,255,255,0.8); 
    background: rgba(255,255,255,0.7);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.tag:hover {
    background: #ffffff;
    border-color: var(--primary);
    transform: scale(1.02);
}
.tag-name { 
    cursor: pointer; 
    border-right: 1px solid rgba(100, 116, 139, 0.2); 
    padding-right: 6px; 
}
.tag-name:hover { 
    text-decoration: underline; 
}
.tag-group-btn { 
    cursor: pointer; 
    font-size: 0.7rem; 
    font-weight: 600; 
    border-right: 1px solid rgba(100, 116, 139, 0.2); 
    padding-right: 6px; 
    opacity: 0.8;
}
.tag-group-btn:hover { 
    text-decoration: underline; 
    opacity: 1; 
}
.tag-del { 
    cursor: pointer; 
    font-size: 0.9rem; 
    line-height: 1; 
    opacity: 0.6; 
}
.tag-del:hover { 
    opacity: 1; 
    color: var(--danger); 
}

.participant-selector { 
    background: rgba(248, 250, 252, 0.4); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-sm); 
    padding: 10px; 
    margin-bottom: 8px; 
    margin-top: 14px; 
}

.participant-row { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    flex-wrap: nowrap; 
    padding: 4px 8px; 
    background: #fff; 
    border: 1px solid var(--border); 
    border-radius: var(--radius-sm); 
    margin-bottom: 4px; 
    box-shadow: var(--shadow-sm); 
    gap: 6px; 
    overflow-x: auto;
}
.participant-row::-webkit-scrollbar { 
    display: none; 
}
.inputs-group { 
    display: flex; 
    gap: 4px; 
    flex: none; 
}
.participant-row input[type="number"] { 
    width: 80px; 
    padding: 4px 6px; 
    margin: 0; 
    font-size: 0.82rem; 
    text-align: right; 
    border-radius: var(--radius-sm); 
    flex: none;
}

.part-personal { 
    background: #f8fafc; 
}
.part-fixed { 
    background: #fffbeb; 
    border-color: #fde68a; 
}
.part-fixed:focus { 
    border-color: #f59e0b; 
    box-shadow: inset 0 0 0 1px #f59e0b; 
}

.checkbox-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 0.88rem; 
    cursor: pointer; 
    font-weight: 700; 
    flex: 1; 
    min-width: 0; 
    white-space: nowrap;
}
.checkbox-item input[type="checkbox"] { 
    width: 16px; 
    height: 16px; 
    margin: 0; 
    cursor: pointer; 
    accent-color: var(--primary); 
    flex: none;
}
.checkbox-item span { 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.ledger-card { 
    padding-top: 0; 
    display: flex; 
    flex-direction: column; 
    min-height: 400px; 
    position: relative; 
}

.sticky-ledger-header {
    position: sticky; 
    top: 0; 
    background: rgba(255,255,255,0.9); 
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
    padding: 8px 0 6px 0; 
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px; 
    border-radius: var(--radius) var(--radius) 0 0;
}

#ledger-toggle-icon { 
    display: inline-block; 
}
.ledger-collapsed #ledger-toggle-icon { 
    transform: rotate(180deg); 
}
.ledger-collapsed #expense-list { 
    display: none; 
}
.card.ledger-card.ledger-collapsed { 
    min-height: 0; 
    padding-bottom: 8px; 
}

/* Ledger expense card upgrade - Compact style */
.expense-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    padding: 8px 12px; 
    border-radius: var(--radius-sm); 
    margin-bottom: 8px; 
    gap: 8px; 
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01); 
    flex-wrap: wrap; 
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.expense-item:last-child { 
    margin-bottom: 0; 
}
.expense-item:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.2);
    transform: translateX(4px);
    box-shadow: 0 8px 16px -6px rgba(15, 23, 42, 0.05);
}
.expense-item.ignored { 
    opacity: 0.5; 
    filter: grayscale(0.8); 
    background: rgba(248, 250, 252, 0.5) !important; 
    border-color: var(--border) !important;
}
.expense-item.is-editing { 
    border: 2px solid var(--primary) !important; 
    background-color: #ffffff !important; 
    box-shadow: var(--shadow-md) !important;
}
.expense-item.updated-flash { 
    background-color: var(--primary-glow) !important; 
    border-color: var(--primary) !important; 
    box-shadow: 0 0 12px var(--primary-glow) !important;
    transform: scale(1.02) translateX(4px);
}

.expense-details { 
    flex: 1; 
    min-width: 180px; 
}
.expense-amount-actions { 
    display: flex; 
    flex-direction: column; 
    align-items: flex-end; 
    gap: 6px; 
    min-width: 90px; 
}
.expense-amount { 
    font-weight: 900; 
    text-align: right; 
    font-size: 1.1rem; 
    color: #0f172a; 
    letter-spacing: -0.02em;
}
.expense-item.ignored .expense-amount { 
    text-decoration: line-through; 
    color: var(--secondary); 
}
.expense-actions { 
    display: flex; 
    gap: 4px; 
    flex-wrap: wrap; 
    justify-content: flex-end;
}

.owed { 
    color: var(--green); 
    font-weight: 800; 
}
.owes { 
    color: var(--red); 
    font-weight: 800; 
}
.balance-item { 
    display: flex; 
    justify-content: space-between; 
    padding: 8px 0; 
    font-size: 0.95rem; 
    border-bottom: 1px solid var(--border);
}
.balance-item:last-child { 
    border-bottom: none; 
}

.settlement-box { 
    background: rgba(248, 250, 252, 0.5); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-sm); 
    padding: 10px 12px; 
    margin-top: 12px;
}
.settlement-item { 
    display: flex; 
    justify-content: space-between; 
    padding: 6px 0; 
    border-bottom: 1px dashed var(--border); 
    font-size: 0.95rem;
}
.settlement-item:last-child { 
    border-bottom: none; 
}
.section-label { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    color: var(--secondary); 
    font-weight: 800; 
    letter-spacing: 0.05em; 
    margin-bottom: 8px; 
    margin-top: 14px;
}

.global-stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 8px; 
    margin-bottom: 16px; 
}
.global-stat-box { 
    background: rgba(255, 255, 255, 0.6); 
    backdrop-filter: blur(8px);
    border: 1px solid var(--border); 
    border-radius: var(--radius-sm); 
    padding: 10px 12px; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: flex-start; 
    box-shadow: var(--shadow-sm); 
    position: relative; 
    overflow: hidden;
}
.global-stat-label { 
    font-size: 0.7rem; 
    color: var(--secondary); 
    text-transform: uppercase; 
    font-weight: 800; 
    letter-spacing: 0.05em; 
    margin-bottom: 4px;
}
.global-stat-value { 
    font-size: 1.25rem; 
    font-weight: 900; 
    color: var(--text); 
    letter-spacing: -0.02em; 
    line-height: 1.2;
}

.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 10px; 
    margin-bottom: 12px; 
}
.stat-card { 
    background: var(--card-bg); 
    padding: 12px; 
    border-radius: var(--radius-sm); 
    border: 1px solid var(--border); 
    font-size: 0.88rem; 
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat-card:hover {
    transform: translateY(-1.5px);
    box-shadow: var(--shadow-md);
    background: #ffffff;
}
.stat-name { 
    font-weight: 900; 
    margin-bottom: 4px; 
    font-size: 1.1rem; 
    letter-spacing: -0.02em;
}
.stat-members { 
    font-size: 0.78rem; 
    color: var(--secondary); 
    font-weight: 500; 
    margin-bottom: 10px; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 6px;
}

.split-type-select { 
    padding: 4px 8px; 
    font-size: 0.82rem; 
    margin: 0; 
    width: auto; 
    font-weight: 700; 
    color: var(--primary); 
    border-color: var(--border); 
    background: #ffffff; 
    box-shadow: none;
}

/* Category filter buttons style - Compact */
.cat-filter-btn { 
    border: 1px solid var(--border); 
    padding: 4px 10px; 
    border-radius: 16px; 
    font-size: 0.72rem; 
    font-weight: 700; 
    cursor: pointer; 
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); 
    background: #fff; 
    line-height: 1.2;
    box-shadow: var(--shadow-sm);
}
.cat-filter-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.currency-selector {
    background: #ffffff; 
    border: 1px solid var(--border); 
    color: var(--primary);
    padding: 6px 10px; 
    border-radius: var(--radius-sm); 
    font-weight: 800; 
    font-size: 0.82rem; 
    width: auto;
    text-transform: uppercase;
}
.rate-display { 
    font-size: 0.78rem; 
    color: var(--secondary); 
    margin-left: 6px; 
    font-weight: 500; 
}

.display-toggle-container {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    background: rgba(248, 250, 252, 0.5); 
    padding: 8px 10px; 
    border-radius: var(--radius-sm); 
    border: 1px solid var(--border); 
    margin-bottom: 12px;
}

details.indiv-details { 
    margin-top: 14px; 
    padding-top: 10px; 
    border-top: 1px dashed var(--border); 
}
details.indiv-details summary { 
    font-size: 0.78rem; 
    font-weight: 800; 
    text-transform: uppercase; 
    color: var(--secondary); 
    cursor: pointer; 
    list-style: none; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
details.indiv-details summary::-webkit-details-marker { 
    display: none; 
}
details.indiv-details summary::after { 
    content: '▼'; 
    font-size: 0.65rem; 
}
details.indiv-details[open] summary::after { 
    transform: rotate(180deg); 
}
.indiv-content { 
    margin-top: 10px; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}

#mini-calculator {
    display: none; 
    position: fixed; 
    bottom: 20px; 
    right: 20px;
    background: rgba(254, 240, 138, 0.75); 
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6); 
    border-radius: var(--radius); 
    padding: 12px; 
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15); 
    z-index: 10001; 
    width: 200px;
}
@media (max-width: 1023px) {
    #mini-calculator { 
        bottom: 80px; 
        left: calc(50% - 100px); 
    }
}

#mini-calendar {
    display: none; 
    position: fixed; 
    bottom: 20px; 
    right: 240px;
    background: rgba(187, 247, 208, 0.75); 
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6); 
    border-radius: var(--radius); 
    padding: 12px; 
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15); 
    z-index: 10001; 
    width: 240px;
    flex-direction: column;
}
@media (max-width: 1023px) {
    #mini-calendar { 
        bottom: 120px; 
        left: calc(50% - 120px); 
    }
}

.modal-overlay {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(15, 23, 42, 0.25); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000; 
    align-items: center; 
    justify-content: center;
}
.modal-overlay.active { 
    display: flex; 
    animation: fadeIn 0.25s ease; 
}
@keyframes fadeIn { 
    from { opacity: 0; } 
    to { opacity: 1; } 
}

/* Premium Modal Layout - Compact */
.notes-modal {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius);
    width: 94%; 
    max-width: 1200px;
    height: 84vh; 
    max-height: 850px;
    display: flex; 
    flex-direction: column; 
    box-shadow: var(--shadow-lg);
    overflow: visible; 
    border: 1px solid rgba(255, 255, 255, 0.6);
}
.notes-header {
    padding: 12px 18px; 
    border-bottom: 1px solid var(--border);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    background: rgba(248, 250, 252, 0.6); 
    flex-wrap: wrap; 
    gap: 8px;
}
.notes-body { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    background: #fff; 
    position: relative;
}
#quill-editor { 
    flex: 1; 
    overflow-y: auto; 
    font-family: 'Plus Jakarta Sans', sans-serif; 
    font-size: 0.95rem; 
    color: var(--text); 
}
.ql-toolbar.ql-snow { 
    border: none !important; 
    border-bottom: 1px solid var(--border) !important; 
    font-family: 'Plus Jakarta Sans', sans-serif; 
    padding: 8px 18px !important; 
    background: rgba(248, 250, 252, 0.6);
}
.ql-container.ql-snow { 
    border: none !important; 
    font-family: 'Plus Jakarta Sans', sans-serif; 
    font-size: 1rem;
}
.ql-editor p { 
    margin-bottom: 8px; 
}

.ql-tooltip { 
    max-width: 90vw; 
    box-sizing: border-box; 
    z-index: 10; 
}
.ql-snow .ql-tooltip[data-mode="link"]::before { 
    content: "Link:"; 
}

#notes-toc-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 250px;
    overflow-y: auto;
    width: 200px;
    z-index: 100;
}
.toc-item {
    padding: 8px 12px;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
}
.toc-item:last-child { 
    border-bottom: none; 
}
.toc-item:hover { 
    background: var(--primary-light); 
    color: var(--primary); 
    font-weight: 700; 
}

.ql-editor { 
    scroll-behavior: smooth; 
}

/* --- TAGS STYLING --- */
.tag-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 4px;
    margin-top: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.tag-pill:hover { 
    filter: brightness(0.92); 
}

.suggestions-popup {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 180px;
    overflow-y: auto;
    z-index: 1000;
    width: 100%;
}
.suggestion-item {
    padding: 8px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}
.suggestion-item:hover { 
    background: var(--primary-light); 
    color: var(--primary);
    font-weight: 700;
}

/* Currency Picker */
.currency-picker {
    position: fixed;
    transform: translateX(-50%);
    margin-top: 4px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    min-width: 220px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 2147483647;
    display: none;
    flex-direction: column;
}

.currency-picker.show {
    display: flex;
}

.currency-picker-section-label {
    font-size: 0.7rem;
    color: var(--secondary);
    font-weight: 700;
    padding: 6px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
}

.currency-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f1f5f9;
}

.currency-picker-item:last-child {
    border-bottom: none;
}

.currency-picker-item:hover {
    background: #f1f5f9;
}

.currency-picker-item.recent {
    background: #fffbeb;
}

.currency-picker-item.recent:hover {
    background: #fef3c7;
}

.currency-picker-item.base-usd {
    background: #eff6ff;
}

.currency-picker-item.base-usd:hover {
    background: #dbeafe;
}

.currency-picker-flag {
    font-size: 1.1rem;
}

.currency-picker-code {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
}

.currency-picker-name {
    font-size: 0.8rem;
    color: var(--secondary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-offline-active {
    background: #fffbeb !important;
    border-color: #f59e0b !important;
    color: #b45309 !important;
    font-weight: 800 !important;
    box-shadow: 0 0 0 1px #fde68a;
}

.btn-offline-active:hover {
    background: #fef3c7 !important;
    border-color: #d97706 !important;
    color: #92400e !important;
}

.settle-up-btn {
    padding: 3px 8px;
    font-size: 0.78rem;
    font-weight: 800;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--green);
    border-radius: 6px;
    white-space: nowrap;
}

.settle-up-btn:hover {
    background: #dcfce7;
    border-color: #4ade80;
    color: #047857;
}

#cloud-update-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 12px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    color: #92400e;
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

#cloud-update-banner button {
    flex: none;
    background: #f59e0b;
    color: #ffffff;
    padding: 4px 10px;
    font-size: 0.78rem;
}

#cloud-update-banner button:hover {
    background: #d97706;
}


