* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --success: #10b981;
    --success-light: #34d399;
    --error: #ef4444;
    --error-light: #f87171;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --accent: #06b6d4;
    --accent-dark: #0891b2;
    
    --background: #0f0f23;
    --surface: #1a1a2e;
    --surface-2: #16213e;
    --surface-3: #0f3460;
    --border: #374151;
    --border-light: #4b5563;
    
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-light: #94a3b8;
    --text-muted: #64748b;
    
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -1px rgb(139 92 246 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -2px rgb(139 92 246 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 10px 10px -5px rgb(139 92 246 / 0.2);
    --shadow-glow: 0 0 20px rgb(139 92 246 / 0.3);
    
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 64px;
    --header-height-large: 25vh;
    --bottom-nav-height: 72px;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Roboto', system-ui, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #1a1a2e 100%);
    color: var(--text);
    line-height: 1.5;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: fixed;
    width: 100%;
}

.app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--background) 0%, #1a1a2e 100%);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: var(--transition);
    z-index: 1;
    overflow: hidden;
}

.screen.active {
    opacity: 1;
    transform: translateX(0);
    z-index: 2;
}

.top-header {
    height: var(--header-height);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 10;
    border-bottom: 1px solid var(--primary);
    min-width: 0;
    flex-shrink: 0;
}

#groupsScreen .top-header {
    height: var(--header-height-large);
    flex-direction: column;
    justify-content: center;
    padding: 20px 16px;
}

#groupsScreen .header-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    max-width: 600px;
}

.main-logo {
    height: 140px;
    width: auto;
    max-width: 95%;
    object-fit: contain;
    filter: drop-shadow(var(--shadow-glow));
}

.top-header h1 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex: 1;
    text-align: center;
    margin: 0 8px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
    border: 1px solid var(--primary);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 40px;
    flex-shrink: 0;
}

.home-btn:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.home-icon {
    font-size: 14px;
}

.options-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--border-radius);
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.options-btn:hover {
    background: var(--surface-2);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.language-select {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 6px 10px;
    border-radius: var(--border-radius);
    font-size: 13px;
    cursor: pointer;
    min-height: 32px;
    transition: var(--transition);
}

.language-select:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgb(139 92 246 / 0.2);
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
    height: 0;
    -webkit-overflow-scrolling: touch;
}

#groupsScreen .screen-content {
    padding-bottom: 16px;
}

.create-group-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.group-input {
    width: 100%;
    border: 2px solid var(--border);
    background: var(--surface-2);
    padding: 16px;
    border-radius: var(--border-radius);
    font-size: 16px;
    color: var(--text);
    margin-bottom: 16px;
    transition: var(--transition);
}

.group-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(139 92 246 / 0.3), var(--shadow-glow);
}

.currency-row {
    display: flex;
    gap: 12px;
}

.currency-select {
    flex: 1;
    border: 2px solid var(--border);
    background: var(--surface-2);
    padding: 16px;
    border-radius: var(--border-radius);
    font-size: 16px;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.currency-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(139 92 246 / 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    box-shadow: var(--shadow);
    min-height: 52px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 12px 20px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 44px;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-add {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    min-height: 52px;
    min-width: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add:hover {
    background: linear-gradient(135deg, var(--success-light) 0%, #059669 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 20px rgb(16 185 129 / 0.4);
}

.btn-remove {
    background: linear-gradient(135deg, var(--error) 0%, var(--error-light) 100%);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 30px;
}

.btn-remove:hover {
    background: linear-gradient(135deg, var(--error-light) 0%, #dc2626 100%);
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgb(239 68 68 / 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error) 0%, var(--error-light) 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 36px;
}

.btn-danger:hover {
    background: linear-gradient(135deg, var(--error-light) 0%, #dc2626 100%);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgb(239 68 68 / 0.4);
}

.groups-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.group-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.group-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    opacity: 0;
    transition: var(--transition);
}

.group-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.group-card:hover::before {
    opacity: 1;
}

.group-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.currency-badge {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow);
}

.group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.group-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.summary-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 20px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 500px;
}

.stat-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: var(--border-radius-lg);
    text-align: center;
    box-shadow: var(--shadow);
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.stat-card.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 30px rgb(139 92 246 / 0.3);
}

.stat-card.success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    color: white;
    border-color: var(--success);
    box-shadow: 0 0 30px rgb(16 185 129 / 0.3);
}

.stat-card.warning {
    background: linear-gradient(135deg, var(--warning) 0%, var(--warning-light) 100%);
    color: white;
    border-color: var(--warning);
    box-shadow: 0 0 30px rgb(245 158 11 / 0.3);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
    line-height: 1.1;
    text-shadow: 0 2px 4px rgb(0 0 0 / 0.3);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    opacity: 0.9;
    line-height: 1.3;
}

.stat-icon {
    font-size: 18px;
    margin-bottom: 8px;
    opacity: 0.8;
}

.participants-section {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.section-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
}

.section-header h3 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.add-participant-section {
    margin-bottom: 20px;
}

.participant-input-row {
    display: flex;
    gap: 12px;
}

.participants-list {
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 12px;
    min-height: 60px;
}

.participant-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    margin-bottom: 6px;
    transition: var(--transition);
}

.participant-display:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.participant-display:last-child {
    margin-bottom: 0;
}

.participant-name {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.expense-section {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.expense-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-section label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input, .form-select {
    border: 2px solid var(--border);
    background: var(--surface-2);
    padding: 16px;
    border-radius: var(--border-radius);
    font-size: 16px;
    color: var(--text);
    transition: var(--transition);
    min-height: 52px;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(139 92 246 / 0.3);
}

.amount-input {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: var(--primary);
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
}

.selection-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.selection-btn {
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: var(--transition);
    min-height: 32px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selection-btn:hover {
    background: linear-gradient(135deg, var(--text-secondary) 0%, var(--text-light) 100%);
    color: white;
    transform: translateY(-1px);
}

.selection-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.participants-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    background: var(--surface-2);
    padding: 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}

.participant-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    min-height: 38px;
}

.participant-checkbox:hover {
    border-color: var(--primary-light);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    box-shadow: var(--shadow);
}

.participant-checkbox.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-glow);
}

.participant-checkbox input {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.participant-checkbox label {
    flex: 1;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.balance-container {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
}

.balance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

.balance-table th,
.balance-table td {
    padding: 16px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    word-wrap: break-word;
    overflow: hidden;
}

.balance-table th {
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.balance-table th:nth-child(1) { width: 30%; }
.balance-table th:nth-child(2) { width: 25%; }
.balance-table th:nth-child(3) { width: 25%; }
.balance-table th:nth-child(4) { width: 20%; }

.balance-table td:last-child,
.balance-table th:last-child {
    text-align: right;
}

.balance-positive {
    color: var(--success);
    font-weight: 800;
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgb(16 185 129 / 0.3);
}

.balance-negative {
    color: var(--error);
    font-weight: 800;
    background: linear-gradient(135deg, var(--error) 0%, var(--error-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgb(239 68 68 / 0.3);
}

.payments-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.payment-suggestion {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.payment-suggestion:hover {
    border-left-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.export-section {
    margin-bottom: 24px;
}

.expenses-history {
    margin-bottom: 24px;
}

.expenses-toggle {
    width: 100%;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    min-height: 60px;
}

.expenses-toggle:hover {
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
    border-color: var(--primary);
}

.expenses-toggle.expanded {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-glow);
}

#expenseCount {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 4px 10px;
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 800;
    margin-left: 12px;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow);
}

.expenses-toggle.expanded #expenseCount {
    background: linear-gradient(135deg, white 0%, #f8fafc 100%);
    color: var(--primary);
}

#expenseToggleIcon {
    font-size: 16px;
    transition: var(--transition);
    font-weight: bold;
}

.expenses-toggle.expanded #expenseToggleIcon {
    transform: rotate(180deg);
}

.expenses-list-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.expenses-list-container.expanded {
    max-height: 2000px;
    transition: max-height 0.3s ease-in;
}

.expense-item {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.expense-item:hover {
    border-left-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.expense-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    display: flex;
    box-shadow: 0 -8px 32px rgb(0 0 0 / 0.3), 0 -4px 16px rgb(139 92 246 / 0.1);
    z-index: 100;
    border-top: 1px solid var(--primary);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    padding: 8px 4px;
    min-height: var(--bottom-nav-height);
    position: relative;
}

.nav-item.active {
    color: var(--primary);
    background: linear-gradient(135deg, transparent, rgb(139 92 246 / 0.1));
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: 0 0 10px rgb(139 92 246 / 0.5);
}

.nav-item:hover:not(.active) {
    background: var(--surface-2);
    color: var(--text);
    transform: translateY(-1px);
}

.nav-icon {
    font-size: 20px;
    margin-bottom: 4px;
    transition: var(--transition);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    line-height: 1.2;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-style: italic;
    font-size: 16px;
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.hidden {
    display: none !important;
}

.rotation-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.rotation-content {
    padding: 40px 20px;
    max-width: 400px;
}

.rotation-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotateDevice 2s ease-in-out infinite;
}

.rotation-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rotation-content p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

@keyframes rotateDevice {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

@media (max-width: 768px) and (orientation: landscape) {
    .rotation-overlay {
        display: flex;
    }
    
    .app {
        display: none;
    }
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-2);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--accent-dark) 100%);
}

@media (max-width: 640px) {
    .top-header {
        padding: 0 12px;
    }
    
    #groupsScreen .top-header {
        padding: 20px 12px;
    }
    
    #groupsScreen .header-actions {
        top: 12px;
        right: 12px;
    }
    
    .main-logo {
        height: 120px;
    }
    
    .home-btn span:not(.home-icon) {
        display: none;
    }
    
    .home-btn {
        padding: 8px 10px;
        gap: 0;
        min-width: 40px;
    }
    
    .summary-container {
        min-height: 35vh;
        padding: 10px 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        max-width: 400px;
    }
    
    .stat-card {
        padding: 12px 8px;
        min-height: 80px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .stat-icon {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .balance-table {
        font-size: 12px;
    }
    
    .balance-table th,
    .balance-table td {
        padding: 12px 8px;
    }
    
    .balance-table th:nth-child(1) { width: 35%; }
    .balance-table th:nth-child(2) { width: 20%; }
    .balance-table th:nth-child(3) { width: 20%; }
    .balance-table th:nth-child(4) { width: 25%; }
    
    .nav-item span {
        font-size: 9px;
    }
    
    .group-meta {
        font-size: 12px;
        gap: 8px;
    }
    
    .expense-meta {
        font-size: 12px;
        gap: 8px;
    }
    
    .screen-content {
        padding: 12px;
        padding-bottom: calc(var(--bottom-nav-height) + 12px);
    }
    
    .form-input, .form-select, .btn-primary {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .balance-table th,
    .balance-table td {
        padding: 10px 6px;
        font-size: 11px;
    }
    
    .balance-table th:nth-child(1) { width: 30%; }
    .balance-table th:nth-child(2) { width: 23%; }
    .balance-table th:nth-child(3) { width: 23%; }
    .balance-table th:nth-child(4) { width: 24%; }
    
    .stats-grid {
        max-width: 320px;
        gap: 10px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .top-header h1 {
        font-size: 16px;
    }
    
    .main-logo {
        height: 105px;
    }
}

@media (max-width: 360px) {
    .screen-content {
        padding: 8px;
        padding-bottom: calc(var(--bottom-nav-height) + 8px);
    }
    
    .balance-table th,
    .balance-table td {
        padding: 8px 4px;
        font-size: 10px;
    }
    
    .stats-grid {
        max-width: 300px;
    }
    
    .create-group-card,
    .group-card {
        padding: 16px;
    }
    
    .main-logo {
        height: 90px;
    }
}
