* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 16px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 24px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.home-button {
    display: inline-block;
    color: #5a67d8;
    text-decoration: none;
    padding: 8px 16px;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.home-button:hover {
    background: #f7fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.left-panel,
.right-panel {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.todo-section h2,
.completed-section h2 {
    color: #1a202c;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.todo-section h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #5a67d8;
    border-radius: 2px;
}

.completed-section h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #48bb78;
    border-radius: 2px;
}

.add-todo {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.add-todo input {
    flex: 1;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #f7fafc;
}

.add-todo input:focus {
    outline: none;
    border-color: #5a67d8;
    background: white;
}

.add-todo input::placeholder {
    color: #a0aec0;
}

.add-todo button {
    padding: 12px 20px;
    background: #5a67d8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.add-todo button:hover {
    background: #4c51bf;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(90, 103, 216, 0.3);
}

.add-todo button:active {
    transform: translateY(0);
}

.todo-list,
.completed-list {
    list-style: none;
    min-height: 60px;
}

.todo-item,
.completed-item {
    background: #f7fafc;
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.todo-item:hover {
    background: white;
    border-color: #cbd5e0;
    transform: translateX(2px);
}

.todo-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #48bb78;
    border-radius: 4px;
}

.todo-item label {
    flex: 1;
    cursor: pointer;
    font-size: 1rem;
    color: #2d3748;
    line-height: 1.5;
}

.completed-item {
    background: #f0fff4;
    border-color: #c6f6d5;
}

.completed-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #48bb78;
    border-radius: 4px;
}

.completed-item label {
    flex: 1;
    cursor: pointer;
}

.completed-item .item-text {
    text-decoration: line-through;
    color: #718096;
    font-size: 1rem;
    margin-bottom: 4px;
}

.completed-item .item-date {
    font-size: 0.8rem;
    color: #a0aec0;
}

.completed-item .delete-btn {
    background: #fc8181;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.completed-item .delete-btn:hover {
    background: #f56565;
    transform: scale(1.05);
}

.completed-item .delete-btn:active {
    transform: scale(0.98);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .home-button {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .left-panel,
    .right-panel {
        padding: 16px;
    }

    .todo-section,
    .completed-section {
        margin-bottom: 0;
    }

    .todo-section h2,
    .completed-section h2 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .add-todo {
        flex-direction: column;
        gap: 8px;
    }

    .add-todo button {
        width: 100%;
        padding: 12px;
    }

    .todo-item,
    .completed-item {
        padding: 12px;
    }

    .todo-item label,
    .completed-item .item-text {
        font-size: 0.95rem;
    }

    .completed-item .item-date {
        font-size: 0.75rem;
    }
}

/* Tablet Optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
    }

    .main-content {
        gap: 16px;
    }

    .left-panel,
    .right-panel {
        padding: 20px;
    }
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
    .todo-item input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }

    .add-todo input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px;
    }

    .todo-item label {
        padding: 4px 0;
    }

    .completed-item .delete-btn {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
}

/* Empty state styling */
.todo-list:empty::after,
.completed-list li[style*="text-align: center"] {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: #a0aec0;
    font-size: 0.9rem;
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    .todo-list,
    .completed-list {
        max-height: none;
    }
}

/* Focus states for accessibility */
.add-todo button:focus-visible,
.home-button:focus-visible,
.completed-item .delete-btn:focus-visible {
    outline: 2px solid #5a67d8;
    outline-offset: 2px;
}

.todo-item input[type="checkbox"]:focus-visible {
    outline: 2px solid #48bb78;
    outline-offset: 2px;
}

/* Family Member Section */
.family-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.manage-family-btn {
    background: #5a67d8;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 15px;
}

.manage-family-btn:hover {
    background: #4c51bf;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(90, 103, 216, 0.3);
}

.manage-family-btn:active {
    transform: translateY(0);
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    color: #4a5568;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.filter-btn.active {
    background: #5a67d8;
    border-color: #5a67d8;
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2d3748;
    font-size: 1.5rem;
}

.add-family-member {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.add-family-member input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: #f7fafc;
    transition: all 0.2s;
}

.add-family-member input:focus {
    outline: none;
    border-color: #5a67d8;
    background: white;
}

.add-family-member button {
    background: #5a67d8;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.add-family-member button:hover {
    background: #4c51bf;
    transform: translateY(-1px);
}

.close-modal-btn {
    width: 100%;
    background: #718096;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: #4a5568;
}

/* Person Select */
.person-select {
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #f7fafc;
    cursor: pointer;
    transition: all 0.2s;
}

.person-select:hover {
    border-color: #cbd5e0;
    background: white;
}

.person-select:focus {
    outline: none;
    border-color: #5a67d8;
    background: white;
}

/* Person Checkboxes */
.person-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.person-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.person-checkbox-label:hover {
    background: #edf2f7;
}

.person-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #5a67d8;
}

.person-checkbox-label span {
    font-size: 0.95rem;
    color: #2d3748;
}

/* Person Badge */
.person-badge {
    display: inline-block;
    background: #5a67d8;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* Family List */
.family-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.manage-family-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
}

.manage-family-item span {
    color: #2d3748;
    font-weight: 500;
    font-size: 0.95rem;
}

.manage-family-item button {
    background: #fc8181;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.manage-family-item button:hover {
    background: #f56565;
    transform: scale(1.05);
}

/* Add Todo Button */
.add-todo-btn {
    width: 100%;
    background: #5a67d8;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.add-todo-btn:hover {
    background: #4c51bf;
    transform: translateY(-1px);
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #4a5568;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: #f7fafc;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #5a67d8;
    background: white;
}

.form-group input[type="file"] {
    padding: 8px;
    font-size: 0.9rem;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.primary-btn {
    flex: 1;
    background: #5a67d8;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-btn:hover {
    background: #4c51bf;
}

.secondary-btn {
    flex: 1;
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: #cbd5e0;
}

/* Task Content */
.task-content {
    flex: 1;
    cursor: pointer;
    padding: 4px 0;
}

.task-text {
    display: block;
    font-size: 1rem;
    color: #2d3748;
    margin-bottom: 4px;
}

.task-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

/* Reward Badge */
.reward-badge {
    display: inline-block;
    background: #48bb78;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Detail Section */
.detail-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.detail-section:last-of-type {
    border-bottom: none;
}

.detail-section label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.detail-section p {
    margin: 0;
    color: #2d3748;
    line-height: 1.5;
}

#detail-task-person-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.edit-assignment-btn {
    background: #5a67d8;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.edit-assignment-btn:hover {
    background: #4c51bf;
    transform: translateY(-1px);
}

/* Earnings Modal */
.earnings-modal {
    max-width: 600px;
}

.earnings-summary {
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.earnings-stat {
    text-align: center;
}

.earnings-stat.highlight {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.earnings-stat label {
    display: block;
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 8px;
}

.earnings-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
}

.earnings-stat .stat-value.negative {
    color: #fc8181;
}

.redemption-section {
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.redemption-section h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: #2d3748;
}

.redeem-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.redeem-input-group input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.redeem-input-group input:focus {
    outline: none;
    border-color: #5a67d8;
}

.history-section h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: #2d3748;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-entry {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 12px;
    align-items: center;
}

.history-entry.redeemed {
    background: #fff5f5;
}

.history-date {
    font-size: 0.8rem;
    color: #718096;
}

.history-task {
    font-size: 0.9rem;
    color: #2d3748;
}

.history-amount {
    font-size: 1rem;
    font-weight: 700;
    text-align: right;
}

.history-amount.positive {
    color: #48bb78;
}

.history-amount.negative {
    color: #fc8181;
}

/* Member Info */
.member-info {
    flex: 1;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.member-name {
    font-weight: 600;
}

.member-earnings {
    color: #48bb78;
    font-weight: 600;
    font-size: 0.9rem;
}

.earnings-badge {
    background: #48bb78;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 6px;
}

/* Update existing todo-item and completed-item */
.todo-item label {
    display: none; /* Remove the label wrapping functionality */
}

.completed-item label {
    flex: 1;
    cursor: default;
    pointer-events: none;
}

/* Mobile Adjustments for Family Features */
@media (max-width: 768px) {
    .family-section {
        padding: 16px;
    }

    .filter-buttons {
        justify-content: center;
    }

    .filter-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 1.25rem;
    }

    .add-family-member {
        flex-direction: column;
    }

    .add-family-member button {
        width: 100%;
        padding: 12px;
    }

    .person-select {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .person-badge {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .reward-badge {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .earnings-summary {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .earnings-stat .stat-value {
        font-size: 1.25rem;
    }

    .redeem-input-group {
        flex-direction: column;
    }

    .redeem-input-group button {
        width: 100%;
    }

    .history-entry {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .history-amount {
        text-align: left;
    }

    .modal-actions {
        flex-direction: column;
    }

    .earnings-badge {
        font-size: 0.7rem;
    }
}
