/* Clean Revenue App Styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

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

/* Header */
.header {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.nav-links {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.nav-links a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
    background: white;
}

.nav-links a:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.card h2 {
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 20px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    background: white;
    margin: 0;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
    font-size: 0.85rem;
}

th {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

tr:hover {
    background: #f8f9fa;
}

tr:nth-child(even) {
    background: #fafbfc;
}

tr:nth-child(even):hover {
    background: #f8f9fa;
}

/* Specific columns for better fit */
td:nth-child(1), th:nth-child(1) { /* Date */
    width: 90px;
    min-width: 90px;
}

td:nth-child(2), th:nth-child(2) { /* Customer */
    width: 120px;
    min-width: 120px;
    white-space: normal;
    word-break: break-word;
}

td:nth-child(3), th:nth-child(3) { /* Amount */
    width: 90px;
    min-width: 90px;
    text-align: right;
}

td:nth-child(4), th:nth-child(4) { /* Source */
    width: 70px;
    min-width: 70px;
}

td:nth-child(5), th:nth-child(5) { /* External ID */
    width: 140px;
    min-width: 140px;
    font-family: monospace;
    font-size: 0.75rem;
}

td:nth-child(6), th:nth-child(6) { /* GPT Commission */
    width: 90px;
    min-width: 90px;
    text-align: right;
}

td:nth-child(7), th:nth-child(7) { /* GPT Status */
    width: 80px;
    min-width: 80px;
}

td:nth-child(8), th:nth-child(8) { /* Affiliate */
    width: 120px;
    min-width: 120px;
    white-space: normal;
    word-break: break-word;
}

td:nth-child(9), th:nth-child(9) { /* Affiliate Commission */
    width: 90px;
    min-width: 90px;
    text-align: right;
}

td:nth-child(10), th:nth-child(10) { /* Affiliate Status */
    width: 80px;
    min-width: 80px;
}

/* Lists */
ul {
    list-style: none;
    padding: 0;
}

li {
    background: white;
    margin: 8px 0;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #007bff;
}

/* Buttons */
.btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    margin: 5px;
    font-size: 0.9rem;
}

.btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #545b62;
}

.btn-success {
    background: #28a745;
}

.btn-success:hover {
    background: #1e7e34;
}

.btn-danger {
    background: #dc3545;
}

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

.btn-info {
    background: #17a2b8;
}

.btn-info:hover {
    background: #138496;
}

/* Forms */
.form-container {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

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

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Error messages */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #f5c6cb;
}

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

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
}

.stat-value a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.stat-value a:hover {
    color: #007bff;
    text-decoration: underline;
}

.stat-label {
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

/* Status badges */
.status-open {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.8rem;
}

.status-drafted {
    background: #d1ecf1;
    color: #0c5460;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.8rem;
}

.status-paid {
    background: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.8rem;
}

.status-na {
    background: #e2e3e5;
    color: #383d41;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.8rem;
}

/* Summary cards for all-payments */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-cards .card {
    background: white;
    border-left: 4px solid #007bff;
    margin-bottom: 0;
}

.summary-cards .card h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    border-bottom: none;
    padding-bottom: 0;
}

.summary-cards .card p {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

/* Back link */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: white;
    transition: all 0.2s ease;
}

.back-link:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    .nav-links {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-links a {
        width: 100%;
        text-align: center;
    }
    
    .card {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .card h2 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .table-container {
        margin: 0 -15px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    table {
        min-width: 700px;
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 6px 8px;
    }
    
    /* Hide less important columns on mobile */
    th:nth-child(4), td:nth-child(4), /* Source */
    th:nth-child(5), td:nth-child(5), /* External ID */
    th:nth-child(8), td:nth-child(8) { /* Affiliate */
        display: none;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .card {
        padding: 15px;
    }
    
    .card h2 {
        font-size: 1.3rem;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    th, td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}