* {
    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, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

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

h1 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-button {
    background: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.tab-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-content {
    display: none;
}

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

.table-container {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow-x: auto;
    margin-bottom: 20px;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.year-table, .month-table {
    min-width: 600px;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

tbody tr:hover {
    background-color: #f8f9ff;
}

.num {
    text-align: right;
}

.day-name {
    color: #667eea;
    font-weight: 500;
    font-size: 0.85rem;
}

.expandable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.expandable-row:hover {
    background-color: #e8ebff !important;
}

.expandable-row td {
    font-weight: 600;
}

.expand-icon {
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.3s;
    font-size: 1.2rem;
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

.nested-content {
    display: none;
}

.nested-content.visible {
    display: table-row;
}

.nested-table-container {
    padding: 20px;
    background: #f8f9ff;
}

.nested-table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.nested-table thead {
    background: #667eea;
}

.month-header {
    background: #e8ebff !important;
}

.heatmap-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 20px;
}

.heatmap-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.heatmap-cell {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.heatmap-count {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.heatmap-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.auto-selector {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
}

.auto-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.toggle-switch {
    position: relative;
    width: 280px;
    height: 40px;
    background: #e0e0e0;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    padding: 3px;
}

.toggle-option {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    z-index: 2;
    transition: color 0.3s;
    padding: 8px 10px;
}

.toggle-option.active {
    color: white;
}

.toggle-slider {
    position: absolute;
    width: 50%;
    height: 34px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 22px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    left: 3px;
}

.toggle-slider.right {
    transform: translateX(calc(100% - 6px));
}

.add-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s;
    z-index: 1000;
}

.add-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.edit-list-button {
    top: 80px;
}

.data-row {
    display: none;
}

.data-card {
    display: none;
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.data-card-header {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.data-card-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.data-card-row:last-child {
    border-bottom: none;
}

.data-card-label {
    font-weight: 600;
    color: #666;
    font-size: 0.85rem;
}

.data-card-value {
    color: #333;
    text-align: right;
    font-size: 0.9rem;
}

.year-card {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.year-card-header {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 3px solid #667eea;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.year-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.year-card-stat {
    background: #f8f9ff;
    padding: 10px;
    border-radius: 8px;
}

.year-card-stat-label {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 5px;
}

.year-card-stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
}

.month-card {
    background: #f8f9ff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.month-card-header {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.month-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.month-stops {
    display: none;
}

.month-stops.visible {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 90%;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close-button {
    background: none;
    border: none;
    font-size: 2rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    transition: color 0.2s;
}

.close-button:hover {
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.submit-button {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.cancel-button {
    flex: 1;
    background: #e0e0e0;
    color: #666;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.cancel-button:hover {
    background: #d0d0d0;
}

.edit-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.edit-item {
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-item:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
}

.edit-item-info {
    flex: 1;
}

.edit-item-date {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.edit-item-details {
    font-size: 0.9rem;
    color: #666;
}

.edit-item-actions {
    display: flex;
    gap: 10px;
}

.btn-edit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-edit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.btn-delete {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(238, 9, 121, 0.4);
}

.no-editable {
    text-align: center;
    padding: 40px;
    color: #999;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        margin-top: 0;
        order: 5;
    }

    body {
        display: flex;
        flex-direction: column;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 15px;
        order: 1;
        margin-top: 10px;
    }

    .auto-selector {
        order: 2;
    }

    .add-button {
        order: 3;
    }

    .edit-list-button {
        order: 4;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        padding: 15px;
    }

    /* Hide desktop table, show mobile cards */
    table {
        display: none !important;
    }

    .data-card {
        display: block;
    }

    .year-card {
        display: block;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .tab-button {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .auto-selector {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        width: 100%;
        margin: 10px 0;
        z-index: 1000;
        border-radius: 8px;
        justify-content: center;
        padding: 10px 15px;
        flex-direction: column;
        gap: 8px;
    }

    .toggle-switch {
        width: 100%;
    }

    .add-button {
        position: relative;
        width: 100%;
        top: auto !important;
        left: auto;
        right: auto;
        margin: 0 0 10px 0;
        border-radius: 8px;
    }

    .edit-list-button {
        top: auto !important;
    }

    .modal-content {
        width: 95%;
        padding: 25px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .edit-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .edit-item-actions {
        width: 100%;
        margin-top: 10px;
    }

    .btn-edit, .btn-delete {
        flex: 1;
    }

    .tabs {
        justify-content: center;
    }

    .heatmap-container {
        flex-direction: column;
    }

    .heatmap-cell {
        width: 80px;
        height: 80px;
    }
}
