@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Professional color scheme */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.7;
    color: var(--dark);
    background-color: #f1f5f9;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Animated background pattern */
.auth-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    animation: backgroundMove 20s ease-in-out infinite;
}

@keyframes backgroundMove {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

.auth-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 3rem;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    margin-bottom: 2rem;
}

.logo h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo p {
    color: var(--gray);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.auth-form {
    text-align: left;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    font-family: inherit;
    background-color: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--gray-light);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-left: 70px !important;
}

.toggle-password,
.toggle-password-reg {
    position: absolute;
    left: 12px;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    background: var(--light);
    border: none;
    color: var(--gray);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: var(--transition);
    user-select: none;
    z-index: 10;
}

.toggle-password:hover,
.toggle-password-reg:hover {
    color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    background: #fee2e2;
    color: #b91c1c;
    border: 2px solid #fecaca;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.footer {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--gray);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.security-note {
    color: var(--success);
    font-weight: 500;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

/* Dashboard Styles */
.dashboard-page {
    background: linear-gradient(to bottom, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
}

.navbar {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.navbar .logo h2 {
    margin: 0;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

#userName {
    font-weight: 600;
    color: var(--dark);
    padding: 0.5rem 1rem;
    background: var(--light);
    border-radius: 20px;
    font-size: 0.95rem;
}

.btn-logout {
    background: white;
    border: 2px solid var(--border);
    color: var(--dark);
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}

.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.upload-section, .history-section {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    animation: fadeInUp 0.6s ease-out;
    border: 1px solid var(--border);
}

.upload-section h2, .history-section h2 {
    color: var(--dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.instructions {
    color: var(--gray);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.upload-container {
    border: 3px dashed var(--border);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: linear-gradient(to bottom, #f8fafc 0%, white 100%);
}

.upload-container:hover {
    border-color: var(--primary);
    background: linear-gradient(to bottom, #eff6ff 0%, white 100%);
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.1);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-container p {
    margin: 0.5rem 0;
    color: var(--dark);
}

.upload-container p strong {
    color: var(--primary);
}

#browseBtn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    margin-top: 1rem;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

#browseBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.file-info {
    margin-top: 1rem;
    color: var(--gray);
    font-style: italic;
    font-size: 0.9rem;
}

.progress-container {
    margin: 1.5rem 0;
}

.progress-bar {
    height: 10px;
    background: #e2e8f0;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#progressBar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transition: width 0.3s ease;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

#progressBar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#progressText {
    text-align: center;
    color: var(--gray);
    font-weight: 600;
    font-size: 0.9rem;
}

.result-container {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    line-height: 1.6;
    animation: fadeInUp 0.4s ease-out;
}

.result-container.success {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid var(--success);
    color: #065f46;
}

.result-container.error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 2px solid var(--danger);
    color: #b91c1c;
}

.rate-limit-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid #bfdbfe;
    border-radius: var(--border-radius);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
}

.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 700;
    color: var(--dark);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr:last-child td {
    border-bottom: none;
}

.status {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status.success {
    background: #dcfce7;
    color: #15803d;
}

.status.processing {
    background: #ffedd5;
    color: #c2410c;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray);
}

.empty-state p:first-child {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    background: white;
}

#serverStatus {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.1);
}

/* Modal styling */
#registerModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

#registerModal.show {
    display: flex !important;
}

#registerModal .auth-container {
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .navbar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    
    .user-info {
        flex-direction: column;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .auth-container {
        padding: 2rem 1.5rem;
    }
    
    .logo h1 {
        font-size: 1.75rem;
    }
    
    .container {
        padding: 0 1rem;
        margin: 1rem auto;
    }
    
    .upload-section, .history-section {
        padding: 1.5rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background-color: #f1f5f9;
    min-height: 100vh;
}

.auth-page {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    text-align: center;
}

.logo h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.logo p {
    color: var(--gray);
    margin-bottom: 2rem;
}

.auth-form {
    text-align: left;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 0.9rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.error-message {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.footer {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--gray);
}

.security-note {
    color: var(--success);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Dashboard Styles */
.dashboard-page {
    background-color: #f1f5f9;
}

.navbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#userName {
    font-weight: 600;
    color: var(--dark);
}

.btn-logout {
    background: none;
    border: 1px solid var(--gray);
    color: var(--gray);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

.container {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.upload-section, .history-section {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.upload-section h2, .history-section h2 {
    color: var(--dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.instructions {
    color: var(--gray);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.upload-container {
    border: 2px dashed var(--border);
    border-radius: var(--border-radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
}

.upload-container:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

#browseBtn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    margin-top: 0.5rem;
}

#browseBtn:hover {
    background: var(--primary-dark);
}

.file-info {
    margin-top: 0.75rem;
    color: var(--gray);
    font-style: italic;
}

.progress-container {
    margin: 1.5rem 0;
}

.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.result-container {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius);
}

.success {
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #064e3b;
}

.error {
    background: #fef2f2;
    border: 1px solid #ef4444;
    color: #b91c1c;
}

.rate-limit-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--border-radius);
    color: var(--primary);
    font-size: 0.9rem;
}

.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--gray);
}

tr:hover {
    background: #f8fafc;
}

.status {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status.success {
    background: #dcfce7;
    color: #15803d;
}

.status.processing {
    background: #ffedd5;
    color: #c2410c;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
}

.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border);
}

/* Responsive adjustmentss */
@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .navbar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .auth-container {
        padding: 1.5rem;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
}

/* Loading spinner */
.loading-spinner {
    text-align: center;
    padding: 20px;
    color: var(--gray);
    font-style: italic;
}

.loading-spinner::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No branches message */
.no-branches {
    color: var(--warning);
    padding: 10px;
    background: #fef3c7;
    border-radius: var(--border-radius);
    text-align: center;
}

/* ============== Branch-Time Grid Styles ============== */

.branch-time-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.branch-time-header {
    margin-bottom: 1.5rem;
}

.branch-time-header p {
    color: var(--gray);
    font-size: 0.95rem;
}

.branch-time-grid-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}

.branch-time-grid {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    table-layout: fixed;
}

.branch-time-grid th,
.branch-time-grid td {
    border: 1px solid var(--border);
    padding: 0.75rem;
    text-align: center;
    vertical-align: middle;
}

.branch-time-grid th {
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
    position: relative;
    min-width: 120px;
}

.branch-time-grid th.branch-header {
    min-width: 180px;
    text-align: left;
    padding-left: 1rem;
}

.branch-time-grid .branch-name-cell {
    text-align: left;
    padding-left: 1rem;
    font-weight: 500;
    background: #f8fafc;
    min-width: 180px;
}

.branch-time-grid .file-cell {
    padding: 0.5rem;
}

.branch-time-grid .loading-cell,
.branch-time-grid .error-cell,
.branch-time-grid .no-data-cell {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
}

.branch-time-grid .error-cell {
    color: var(--danger);
    background: #fef2f2;
}

/* Cell buttons */
.btn-cell {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-cell.btn-upload {
    background: #f0f9ff;
    color: var(--primary);
    border: 2px dashed var(--primary-light);
}

.btn-cell.btn-upload:hover {
    background: #dbeafe;
    border-color: var(--primary);
}

.btn-cell.btn-has-file {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.btn-cell.btn-has-file:hover {
    background: #bbf7d0;
}

/* Grid legend */
.grid-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.upload {
    background: #f0f9ff;
    border: 2px dashed var(--primary-light);
}

.legend-dot.has-file {
    background: #dcfce7;
    border: 1px solid #86efac;
}

/* Column resizer */
.column-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
}

.column-resizer:hover {
    background: var(--primary-light);
}

th.resizable {
    position: relative;
    user-select: none;
}

/* File Actions Modal */
.modal-small {
    max-width: 400px;
}

.modal-medium {
    max-width: 500px;
}

.file-info-display {
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.file-info-display p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.file-action-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-download {
    flex: 1;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-remove {
    flex: 1;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.file-action-note {
    font-size: 0.8rem;
    color: var(--gray);
    font-style: italic;
    margin: 0;
}

/* Upload modal styles */
.upload-info {
    background: #f0f9ff;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border: 1px solid #bae6fd;
}

.upload-info p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.upload-zone {
    border: 3px dashed var(--border);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-zone .upload-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.file-name-display {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--gray);
    font-style: italic;
}

.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    animation: progress-animation 1.5s ease-in-out infinite;
}

@keyframes progress-animation {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray);
}

/* Responsive for branch-time grid */
@media (max-width: 768px) {
    .branch-time-grid th,
    .branch-time-grid td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .btn-cell {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .file-action-buttons {
        flex-direction: column;
    }
}

/* ============== Excel Editor Modal Styles ============== */

/* Full screen modal */
.modal-fullscreen {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    margin: 0;
}

/* Override modal positioning for fullscreen */
#excelEditorModal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}

#excelEditorModal .modal-content {
    margin: 0;
    border-radius: 0;
}

/* Excel editor header */
.excel-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-bottom: 1px solid #475569;
    color: white;
}

.excel-editor-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.excel-editor-title h3 {
    margin: 0;
    font-size: 1.2rem;
    color: white;
}

.editor-file-info {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.15);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.excel-editor-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.excel-editor-header .modal-close {
    color: white;
    font-size: 1.75rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.excel-editor-header .modal-close:hover {
    opacity: 1;
    color: white;
}

/* Editor action buttons */
.btn-add-row-editor,
.btn-add-col-editor {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: #4f46e5;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-add-row-editor:hover,
.btn-add-col-editor:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

.btn-save-editor {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    background: #10b981;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-save-editor:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
}

.btn-save-editor:disabled {
    background: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

/* Editor body */
.excel-editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.excel-editor-info {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.75rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.excel-editor-info p {
    margin: 0;
    font-size: 0.9rem;
}

.editor-hint {
    color: var(--gray);
    font-style: italic;
    margin-left: auto !important;
}

/* Excel editor container */
.excel-editor-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #f1f5f9;
}

.editor-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray);
}

/* Excel editor table */
.editor-table {
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
    min-width: 100%;
}

.editor-table th,
.editor-table td {
    border: 1px solid #d1d5db;
    position: relative;
}

/* Column headers */
.editor-table th {
    background: linear-gradient(to bottom, #f8fafc 0%, #e2e8f0 100%);
    font-weight: 600;
    color: #475569;
    text-align: center;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    min-width: 100px;
    user-select: none;
}

.editor-table th.corner-cell {
    position: sticky;
    left: 0;
    z-index: 30;
    min-width: 50px;
    width: 50px;
    background: #e2e8f0;
}

.editor-table th .th-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    min-height: 40px;
}

.editor-table th .col-title {
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.editor-table th .col-menu-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.editor-table th:hover .col-menu-btn {
    opacity: 1;
}

.editor-table th .col-menu-btn:hover {
    color: var(--primary);
}

/* Row number column */
.editor-table td.row-num {
    background: #f1f5f9;
    color: #64748b;
    font-weight: 500;
    text-align: center;
    padding: 0.5rem;
    position: sticky;
    left: 0;
    z-index: 10;
    min-width: 50px;
    width: 50px;
    user-select: none;
}

/* Data cells */
.editor-table td {
    padding: 0;
    min-width: 100px;
    height: 32px;
    vertical-align: middle;
}

.editor-table td .cell-input {
    width: 100%;
    height: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-family: inherit;
    box-sizing: border-box;
}

.editor-table td .cell-input:focus {
    outline: none;
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px var(--primary);
}

.editor-table tr:hover td:not(.row-num) {
    background: #fafbfc;
}

.editor-table tr:hover td:not(.row-num) .cell-input {
    background: #fafbfc;
}

.editor-table tr:hover td .cell-input:focus {
    background: #eff6ff;
}

/* Selected cell/row/column */
.editor-table td.selected,
.editor-table th.selected {
    background: #dbeafe !important;
}

/* Column resizer */
.col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 5;
}

.col-resizer:hover,
.col-resizer.resizing {
    background: var(--primary);
}

/* Row resizer */
.row-resizer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 5px;
    cursor: row-resize;
    background: transparent;
    z-index: 5;
}

.row-resizer:hover,
.row-resizer.resizing {
    background: var(--primary);
}

/* Delete buttons */
.delete-col-btn,
.delete-row-btn-editor {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    transition: opacity 0.2s;
    padding: 0.25rem;
}

.delete-col-btn:hover,
.delete-row-btn-editor:hover {
    opacity: 1;
}

.editor-table th .delete-col-btn {
    margin-left: 0.25rem;
}

/* Actions column */
.editor-table td.action-cell {
    text-align: center;
    background: #f8fafc;
    padding: 0;
    width: 40px;
    min-width: 40px;
}

/* Status bar */
.excel-editor-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--gray);
}

.status-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-text.unsaved {
    color: #f59e0b;
}

.status-text.saved {
    color: #10b981;
}

.row-count-text {
    color: #64748b;
}

/* View & Edit button style */
.btn-view-edit {
    flex: 1;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-view-edit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Column/Row context menu */
.editor-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 160px;
    padding: 0.5rem 0;
}

.editor-context-menu button {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    transition: background 0.2s;
}

.editor-context-menu button:hover {
    background: #f3f4f6;
}

.editor-context-menu button.danger {
    color: #ef4444;
}

.editor-context-menu button.danger:hover {
    background: #fef2f2;
}

/* Responsive for Excel editor */
@media (max-width: 768px) {
    .modal-fullscreen {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .excel-editor-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .excel-editor-actions {
        flex-wrap: wrap;
    }
    
    .excel-editor-info {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .editor-hint {
        margin-left: 0 !important;
        width: 100%;
    }
}