/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.workspace-info {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Month selector */
.month-selector {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.month-selector label {
    font-weight: 600;
    color: #555;
}

#month-select {
    padding: 0.5rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

/* Entry form */
.entry-form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.entry-form h2 {
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group.full-width {
    flex: 100%;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.select-with-unit {
    position: relative;
    display: flex;
    align-items: center;
}

.select-with-unit select,
.select-with-unit input {
    flex: 1;
    margin-right: 0.5rem;
}

.unit {
    color: #888;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    height: 100%;
}

#net-display {
    background-color: #f8f9fa;
    color: #666;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-edit {
    background: #28a745;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.btn-edit:hover {
    background: #218838;
}

/* Overall summary */
.overall-summary {
    margin-bottom: 2rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-left: 4px solid;
}

.summary-card.invest {
    border-left-color: #dc3545;
}

.summary-card.payout {
    border-left-color: #28a745;
}

.summary-card.net {
    border-left-color: #007bff;
}

.summary-card.win-rate {
    border-left-color: #ffc107;
}

.summary-card .label {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.summary-card .amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
    word-break: keep-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsible sections */
.monthly-breakdown,
.entries-history {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
}

/* Fixed section header (non-collapsible) */
.section-header-fixed {
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.section-header-fixed h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.section-content-fixed {
    padding: 1.5rem;
}

.section-header {
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.section-header:hover {
    background: #e9ecef;
}

.section-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.toggle-icon {
    font-size: 1.2rem;
    color: #666;
    transition: transform 0.3s ease;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.section-content.expanded {
    max-height: 80vh;
    overflow-y: auto;
}

.section-content > div {
    padding: 1.5rem;
}

/* Monthly entries styling */
.monthly-entry-group {
    margin-bottom: 2rem;
}

.monthly-entry-group h3 {
    background: #f8f9fa;
    padding: 1rem;
    margin: 0 0 1rem 0;
    border-radius: 6px;
    color: #333;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.monthly-entry-group h3:hover {
    background: #e9ecef;
}

.monthly-entry-table {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.monthly-entry-table.collapsed {
    max-height: 0;
}

.monthly-entry-table.expanded {
    max-height: 600px;
    overflow-y: auto;
}

/* Daily entry group styling */
.daily-entry-group {
    margin-bottom: 1.5rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.daily-header {
    background: #f8f9fa;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
}

.daily-date {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.daily-total {
    font-weight: 700;
    font-size: 1.1rem;
}

.daily-entries {
    padding: 0;
}

.entry-card {
    border-bottom: 1px solid #f1f3f4;
    padding: 0.75rem;
    transition: background-color 0.2s ease;
}

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

.entry-card:hover {
    background-color: #f8f9fa;
}

.entry-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.entry-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.entry-info .store {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.entry-info .machine {
    color: #666;
    font-size: 0.9rem;
}

.entry-amounts {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.amount-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.amount-item .label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.125rem;
    font-weight: 600;
}

.amount-item .value {
    font-weight: 700;
    font-size: 1.1rem;
}

.amount-item.net .value {
    font-weight: 700;
    font-size: 1.1rem;
}

.entry-memo {
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.75rem;
    border-left: 3px solid #007bff;
}

.entry-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.9rem;
}

.daily-entry-table th, .daily-entry-table td {
    padding: 0.5rem;
    font-size: 0.85rem;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

td {
    color: #333;
}

tr:hover {
    background-color: #f8f9fa;
}

.no-entries {
    padding: 2rem;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Monthly chart container */
#monthly-chart-container {
    min-height: 200px;
}

.monthly-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    margin-bottom: 0.5rem;
    border-radius: 6px;
}

.monthly-summary-item:last-child {
    margin-bottom: 0;
}

.monthly-summary-item .month {
    font-weight: 600;
    color: #333;
}

.monthly-summary-item .net-amount {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.info {
    background: #007bff;
}

/* 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-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: #333;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 1.5rem;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .summary-card {
        padding: 1rem;
    }
    
    .summary-card .amount {
        font-size: 1.5rem;
        min-width: 0;
    }
    
    .month-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .month-selector label {
        margin-bottom: 0.5rem;
    }
    
    th, td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
    
    /* Mobile-optimized entry cards */
    .daily-entry-group {
        margin-bottom: 1rem;
        border-radius: 6px;
    }
    
    .daily-header {
        padding: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .daily-date {
        font-size: 1rem;
    }
    
    .daily-total {
        font-size: 1.2rem;
        align-self: flex-end;
    }
    
    .entry-card {
        padding: 0.75rem;
    }
    
    .entry-main {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .entry-info {
        gap: 0.125rem;
    }
    
    .entry-info .store {
        font-size: 0.95rem;
    }
    
    .entry-info .machine {
        font-size: 0.85rem;
    }
    
    .entry-amounts {
        gap: 0.5rem;
        justify-content: space-around;
        background: #f8f9fa;
        padding: 0.5rem;
        border-radius: 6px;
    }
    
    .amount-item .label {
        font-size: 0.8rem;
        margin-bottom: 0.1rem;
    }
    
    .amount-item .value {
        font-size: 1rem;
    }
    
    .amount-item.net .value {
        font-size: 1rem;
    }
    
    .entry-memo {
        padding: 0.5rem;
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .entry-actions {
        justify-content: center;
        gap: 0.75rem;
    }
    
    .btn-edit, .btn-danger {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        flex: 1;
        max-width: 120px;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Utility classes */
.text-success {
    color: #28a745 !important;
}

.text-danger {
    color: #dc3545 !important;
}

.text-muted {
    color: #6c757d !important;
}
