* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --primary-dark: #45a049;
    --danger-color: #f44336;
    --danger-light: #ffcdd2;
    --success-light: #c8e6c9;
    --text-dark: #333;
    --text-light: #666;
    --border-color: #ddd;
    --bg-light: #f9f9f9;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 30px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
}

.header-left {
    flex: 0 0 auto;
}

header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
    margin: 0;
}

.settings-btn {
    flex: 0 0 auto;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: rotate(90deg);
}

/* Profile Selector */
.profile-selector {
    position: relative;
}

.profile-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    white-space: nowrap;
}

.profile-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.profile-list {
    padding: 5px;
}

.profile-item {
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.profile-item:hover {
    background: var(--bg-light);
}

.profile-item.active {
    background: var(--success-light);
    font-weight: 600;
}

.profile-name {
    flex: 1;
}

.default-badge {
    background: #ffc107;
    color: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.add-profile-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-light);
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.add-profile-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Profile Management in Settings */
.profile-management-list {
    margin-bottom: 15px;
}

.profile-card {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.profile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.profile-name-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    transition: border-color 0.3s;
}

.profile-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.profile-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon-small {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon-small:hover {
    background: rgba(0, 0, 0, 0.1);
}

.btn-delete:hover {
    background: var(--danger-light);
}

.profile-stats {
    color: var(--text-light);
    font-size: 0.85rem;
}

.month-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 12px;
    gap: 15px;
}

.month-navigation h2 {
    font-size: 1.5rem;
    color: var(--text-dark);
    flex: 1;
    text-align: center;
}

.nav-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.today-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.today-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.calendar-container {
    margin-bottom: 30px;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.day-label {
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
    padding: 10px;
    font-size: 0.9rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

.calendar-day:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.calendar-day.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-day.disabled {
    background: var(--danger-light);
    border-color: var(--danger-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.calendar-day.has-data {
    background: var(--success-light);
    border-color: var(--primary-color);
    font-weight: 600;
}

.day-number {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.day-value {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
}

.calendar-day.today {
    border-color: var(--primary-color);
    border-width: 3px;
}

.summary-section {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-label {
    font-weight: 600;
    color: var(--text-dark);
}

.summary-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.price-input {
    width: 150px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    text-align: right;
}

.price-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.total-amount {
    border-top: 2px solid var(--border-color);
    padding-top: 15px;
    margin-top: 15px;
}

.total-amount .summary-value {
    font-size: 1.5rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--text-dark);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 20px;
}

.last-values-toggle {
    margin-top: 10px;
    margin-bottom: 15px;
    padding: 10px 12px;
    background: var(--bg-light);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.toggle-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    background: white;
    transition: all 0.3s;
}

.toggle-checkbox-label input:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle-checkbox-label input:not(:checked) + .checkmark {
    color: transparent;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.day-total {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-top: 10px;
}

.modal-footer {
    padding: 20px;
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .month-navigation h2 {
        font-size: 1.2rem;
    }

    .calendar-header {
        gap: 4px;
    }

    .calendar-grid {
        gap: 4px;
    }

    .day-label {
        font-size: 0.75rem;
        padding: 4px 2px;
    }

    .calendar-day {
        padding: 2px;
        border-width: 1px;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .day-value {
        font-size: 0.55rem;
        margin-top: 2px;
        white-space: nowrap;
    }

    .summary-row {
        font-size: 1rem;
    }

    .summary-value {
        font-size: 1rem;
    }

    .price-input {
        width: 120px;
    }
}

/* Install prompt */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 999;
    animation: slideUp 0.5s;
}

.install-prompt button {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.install-prompt .close-install {
    background: transparent;
    color: white;
    padding: 0;
    width: 24px;
    height: 24px;
    font-size: 1.5rem;
}

/* Update Notification */
.update-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #2196F3;
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 9999;
    animation: slideDown 0.5s;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.update-notification.fade-out {
    animation: fadeOut 0.3s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

.reload-btn {
    background: white;
    color: #2196F3;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.reload-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Sync Status Bar */
.sync-status {
    background: var(--success-light);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dark);
    border: 2px solid var(--primary-color);
}

.sync-status.sync-error {
    background: var(--danger-light);
    border-color: var(--danger-color);
}

/* Settings Modal - Larger */
.modal-large {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h4 {
    color: var(--text-dark);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.settings-description {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

.settings-note {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 10px;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 20px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.user-email {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Sync Controls */
.sync-controls {
    margin-top: 15px;
}

.setting-item {
    margin-bottom: 20px;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 26px;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(24px);
}

.toggle-text {
    font-size: 1rem;
    color: var(--text-dark);
}

/* Sync Info */
.sync-info {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-synced {
    background: var(--success-light);
    color: #2e7d32;
}

.status-syncing {
    background: #fff3cd;
    color: #856404;
}

.status-error {
    background: var(--danger-light);
    color: var(--danger-color);
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: #e0e0e0;
    border-color: var(--text-light);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    margin-top: 10px;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-icon {
    margin-right: 5px;
}

/* Conflict Resolution Modal */
.conflict-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

.conflict-option {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.conflict-option h4 {
    margin-bottom: 15px;
    color: var(--text-dark);
}

.conflict-details {
    text-align: left;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.conflict-details p {
    margin-bottom: 8px;
}

.warning-text {
    text-align: center;
    color: var(--danger-color);
    margin-top: 15px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    min-width: 250px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease-in-out;
    border-left: 4px solid var(--primary-color);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left-color: var(--primary-color);
}

.notification-error {
    border-left-color: var(--danger-color);
}

.notification-warning {
    border-left-color: #ff9800;
}

.notification-info {
    border-left-color: #2196F3;
}

/* Responsive adjustments for new elements */
@media (max-width: 600px) {
    header {
        flex-wrap: wrap;
        gap: 10px;
    }

    header h1 {
        font-size: 1.8rem;
        order: 1;
        flex: 1 1 100%;
    }

    .header-left {
        order: 2;
    }

    .settings-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        order: 3;
    }

    .profile-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .profile-dropdown {
        min-width: 180px;
    }

    .modal-large {
        max-width: 95%;
        max-height: 95vh;
    }

    .conflict-options {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .btn {
        width: 100%;
    }

    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .profile-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-name-input {
        width: 100%;
    }

    .profile-card-actions {
        justify-content: flex-end;
    }
}

