* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    padding: 20px;
    font-size: 14px;
    line-height: 1.5;
}
.container { max-width: 100%; margin: 0 auto; }
h1 { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 24px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}
.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}
.stat-card h3 { 
    font-size: 13px; 
    color: #666; 
    margin-bottom: 10px;
    font-weight: 500;
}
.stat-card .number { 
    font-size: 32px; 
    font-weight: 700; 
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'tnum' 1;
    text-align: center;
}

.filters {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filters button {
    padding: 10px 18px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.filters button:hover {
    background: #f8f9fa;
}
.filters button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    position: relative;
}
.table-container::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}
.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}
.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 14px 12px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}
th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    font-size: 13px;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    z-index: 100;
    text-align: center !important;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    line-height: 1.3;
}
td {
    font-size: 14px;
    color: #212529;
    text-align: center;
}

/* Sticky columns */
th:nth-child(1), td:nth-child(1) {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 90;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}
th:nth-child(1) {
    z-index: 110;
    background: #f8f9fa;
}

th:nth-child(2), td:nth-child(2) {
    position: sticky;
    left: 80px; /* Width of CID column */
    background: #fff;
    z-index: 89;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}
th:nth-child(2) {
    z-index: 109;
    background: #f8f9fa;
}
tbody tr:hover { 
    background: #f8f9fa;
    transform: scale(1.001);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.badge-stage1 { background: #e3f2fd; color: #1976d2; }
.badge-stage2 { background: #fff3e0; color: #f57c00; }
.badge-stage3 { background: #f3e5f5; color: #7b1fa2; }
.badge-ok { background: #e8f5e9; color: #2e7d32; }
.badge-failed { background: #ffebee; color: #c62828; }
.badge-done { background: #e0e0e0; color: #616161; }

.number { 
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'tnum' 1;
}

.account-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left !important;
}

.cid-cell {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    font-feature-settings: 'tnum' 1;
    text-align: center;
}

.positive { color: #2e7d32; font-weight: 600; }
.negative { color: #c62828; font-weight: 600; }

.header-2line {
    white-space: normal;
    line-height: 1.3;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-content {
    background: white;
    margin: 20px auto;
    padding: 0;
    width: 90%;
    max-width: 800px;
    max-height: calc(100vh - 40px);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: slideDown 0.3s;
    display: flex;
    flex-direction: column;
}
@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 20px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 20px;
    margin: 0;
}
.close {
    color: white;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
}
.close:hover {
    transform: rotate(90deg);
}
.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.modal-footer {
    padding: 20px 30px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: #667eea;
    color: white;
}
.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
}
.btn-secondary {
    background: #e0e0e0;
    color: #333;
}
.btn-secondary:hover {
    background: #d0d0d0;
}
.readonly {
    background: #f5f5f5;
    cursor: not-allowed;
}
.note {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.btn-link {
    display: inline-block;
    padding: 8px 12px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-link:hover {
    background: #5568d3;
    transform: translateY(-1px);
}
