* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

/* Prevent double borders and outlines */
*,
*:before,
*:after {
    border: none;
    outline: none;
}

/* Only add borders where specifically needed */
.header {
    border-bottom: 1px solid #e5e5e7 !important;
}

footer {
    border-top: 1px solid #e5e5e7 !important;
    border-bottom: none !important;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #ffffff;
    color: #1d1d1f;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    min-height: 100vh;
    border: none;
    outline: none;
}

.header {
    background: #ffffff;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.app-title {
    font-size: 24px;
    font-weight: 600;
    color: #1d1d1f;
}

.user-menu { position: relative; }

.auth-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.auth-buttons .btn {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.auth-buttons .btn-outline {
    background: transparent;
    color: #1d1d1f;
    border: 1px solid #e5e5e7;
}

.auth-buttons .btn-outline:hover {
    background: #f8f9fa;
}

.auth-buttons .btn-primary {
    background: #007aff;
    color: #ffffff;
    border: none;
}

.auth-buttons .btn-primary:hover {
    background: #0056cc;
}

.menu-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid #e5e5e7;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1d1d1f;
}

.menu-button:hover { background: #f8f9fa; }

.menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e5e7;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 1000;
    display: none;
    margin-top: 8px;
}

.menu-dropdown.show { display: block; }

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: #1d1d1f;
    font-size: 14px;
    transition: background 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover { background: #f8f9fa; }
.menu-divider { height: 1px; background: #e5e5e7; margin: 8px 0; }
.logout-button { color: #ff3b30; }
.logout-button:hover { background: #ffe5e5; }

.daily-usage-indicator {
    background: #f8f9ff;
    border: 1px solid #e5e5e7;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
}
.daily-usage-indicator h3 { color: #1d1d1f; margin-bottom: 16px; font-size: 18px; font-weight: 600; }
.usage-bar { width: 100%; height: 8px; background: #e5e5e7; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.usage-fill { height: 100%; background: #007aff; border-radius: 4px; transition: width 0.3s ease; width: 0%; }
.usage-text { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.usage-text span:first-child { color: #1d1d1f; font-weight: 500; }
.usage-reset { color: #86868b; font-size: 12px; }

.main-content { padding: 40px 20px; max-width: 900px; margin: 0 auto; }
.user-info { background: #ffffff; border-radius: 16px; padding: 24px; margin-bottom: 32px; border: 1px solid #e5e5e7; }
.user-info h3 { color: #1d1d1f; margin-bottom: 20px; font-size: 18px; font-weight: 600; }
.quota-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.quota-item { background: #ffffff; padding: 20px; border-radius: 12px; border: 1px solid #e5e5e7; text-align: center; }
.quota-item h4 { color: #86868b; font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.quota-item .value { font-size: 24px; font-weight: 600; color: #1d1d1f; }

.config-section { background: #ffffff; border-radius: 16px; padding: 24px; margin-bottom: 32px; border: 1px solid #e5e5e7; }
.config-section h3 { color: #1d1d1f; margin-bottom: 16px; font-size: 18px; font-weight: 600; }
.config-section p { color: #86868b; margin-bottom: 20px; font-size: 15px; }
.column-input { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.column-input input { 
    flex: 1; 
    padding: 12px 16px; 
    border: 1px solid #e5e5e7 !important; 
    border-radius: 8px; 
    font-size: 16px; 
    font-family: inherit; 
    background: #ffffff; 
    color: #1d1d1f; 
    min-width: 150px; 
    transition: border-color 0.2s ease; 
    outline: none !important;
}
.column-input input:focus { 
    border: 1px solid #007aff !important; 
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25) !important;
}

.btn { padding: 12px 20px; border: none; border-radius: 8px; font-size: 16px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-family: inherit; }
.btn-primary { background: #007aff; color: #ffffff; }
.btn-primary:hover { background: #0056cc; }
.btn-secondary { background: #ffffff; color: #1d1d1f; border: 1px solid #e5e5e7; }
.btn-secondary:hover { background: #e5e5e7; }
.btn-success { background: #34c759; color: #ffffff; }
.btn-success:hover { background: #28a745; }
.btn-danger { background: #ff3b30; color: #ffffff; }
.btn-danger:hover { background: #d70015; }

.auth-section { text-align: center; margin-bottom: 32px; padding: 32px; background: #ffffff; border-radius: 16px; border: 1px solid #e5e5e7; }
.auth-section h3 { color: #1d1d1f; margin-bottom: 12px; font-size: 18px; font-weight: 600; }
.auth-section p { color: #86868b; margin-bottom: 24px; font-size: 15px; }

.connected-status { background: #d4edda; border: 1px solid #c3e6cb; border-radius: 16px; padding: 32px; margin-bottom: 32px; text-align: center; }
.connected-status h3 { color: #155724; margin-bottom: 12px; font-size: 18px; font-weight: 600; }
.connected-status p { color: #155724; margin-bottom: 24px; font-size: 15px; }

.auth-button { background: #007aff; color: #ffffff; border: none; padding: 14px 28px; border-radius: 8px; font-size: 16px; font-weight: 500; cursor: pointer; transition: background 0.2s ease; display: inline-flex; align-items: center; gap: 8px; font-family: inherit; }
.auth-button:hover { background: #0056cc; }

.text-input-section { margin-bottom: 32px; }
.text-input-section h3 { color: #1d1d1f; margin-bottom: 16px; font-size: 18px; font-weight: 600; }
.project-input { margin-bottom: 12px; }
.project-name-input { width: 100%; padding: 12px 16px; border: 1px solid #e5e5e7; border-radius: 8px; font-size: 16px; font-family: inherit; background: #ffffff; transition: border-color 0.2s ease; }
.project-name-input:focus { 
    outline: none !important; 
    border: 1px solid #007aff !important; 
    box-shadow: 0 0 0 2px rgba(0,122,255,0.25) !important; 
}
.text-area { 
    width: 100%; 
    min-height: 200px; 
    padding: 16px; 
    border: 1px solid #e5e5e7 !important; 
    border-radius: 12px; 
    font-size: 16px; 
    font-family: inherit; 
    resize: vertical; 
    background: #ffffff; 
    color: #1d1d1f; 
    transition: border-color 0.2s ease; 
    outline: none !important;
}
.text-area:focus { 
    border: 1px solid #007aff !important; 
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25) !important;
}
.input-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.char-counter { color: #86868b; font-size: 14px; }
.button-group { display: flex; gap: 12px; flex-wrap: wrap; }

.process-button { background: #007aff; color: #ffffff; border: none; padding: 14px 24px; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s ease; display: inline-flex; align-items: center; gap: 8px; font-family: inherit; box-shadow: 0 6px 14px rgba(0,122,255,0.15); }
.process-button:hover { background: #0056cc; }
.process-button:disabled { background: #86868b; cursor: not-allowed; }

.add-button { background: #28a745; color: #ffffff; border: none; padding: 14px 24px; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s ease; display: inline-flex; align-items: center; gap: 8px; font-family: inherit; box-shadow: 0 6px 14px rgba(40,167,69,0.15); }
.add-button:hover { background: #218838; }
.add-button:disabled { background: #86868b; cursor: not-allowed; }

.result-section { margin-top: 32px; display: none; }
.result-section h3 { color: #1d1d1f; margin-bottom: 16px; font-size: 18px; font-weight: 600; }
.result-actions { display:flex; align-items:center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.result-text { background: #ffffff; border: 1px solid #e5e5e7; border-radius: 12px; padding: 0; overflow-x: auto; }
.result-text table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-text thead th { position: sticky; top: 0; background: #ffffff; color: #1d1d1f; font-weight: 600; text-align: left; padding: 12px 14px; border-bottom: 1px solid #e5e5e7; }
.result-text tbody td { padding: 12px 14px; border-bottom: 1px solid #f0f0f0; }
.result-text tbody tr:hover { background: #f8f9fa; }
.sheets-link { margin-top: 16px; }
.sheets-link a { color: #007aff; text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.sheets-link a:hover { text-decoration: underline; }

.subscription-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 1000; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.modal-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #ffffff; padding: 32px; border-radius: 16px; max-width: 500px; width: 90%; text-align: center; border: 1px solid #e5e5e7; }
.modal-content h2 { color: #1d1d1f; margin-bottom: 16px; font-size: 24px; font-weight: 600; }
.modal-content p { color: #86868b; margin-bottom: 24px; line-height: 1.5; font-size: 15px; }
.plan-cards { display: flex; justify-content: center; gap: 16px; margin-bottom: 24px; }
.plan-card { background: #ffffff; border: 2px solid #e5e5e7; border-radius: 12px; padding: 24px; cursor: pointer; transition: all 0.2s ease; }
.plan-card:hover { border-color: #007aff; background: #f8f9fa; }
.plan-card.selected { border-color: #007aff; background: #f8f9fa; }
.plan-card h3 { color: #1d1d1f; margin-bottom: 8px; font-size: 16px; font-weight: 600; }
.plan-card .price { font-size: 24px; font-weight: 700; color: #007aff; margin-bottom: 8px; }
.plan-card .features { color: #86868b; font-size: 14px; }
.close-modal { position: absolute; top: 16px; right: 20px; background: none; border: none; font-size: 24px; cursor: pointer; color: #86868b; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background 0.2s ease; }
.close-modal:hover { background: #f8f9fa; }

.loading { display: none; text-align: center; padding: 40px; }
.spinner { width: 40px; height: 40px; border: 3px solid #f5f5f7; border-top: 3px solid #007aff; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 16px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.error-message { background: #ffebee; color: #c62828; padding: 16px; border-radius: 8px; margin: 16px 0; border: 1px solid #ffcdd2; font-size: 14px; }

/* AdSense Styles - Optimized for Policy Compliance */
.ad-section {
    margin: 48px 0; /* Increased margin from interactive elements */
    padding: 24px 16px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    clear: both; /* Ensure proper separation */
    min-height: 120px; /* Prevent layout shift */
}

.ad-container {
    max-width: 728px; /* Standard leaderboard width */
    margin: 0 auto;
    position: relative;
}

.ad-label {
    font-size: 11px;
    color: #999;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 400;
    display: block;
}

.ad-banner {
    min-height: 90px; /* Standard banner height */
    display: block;
    margin: 0 auto;
    background: transparent;
    border: none;
    overflow: hidden;
}

/* Mobile-first responsive ads */
@media (max-width: 768px) {
    .ad-section {
        margin: 32px 0;
        padding: 16px 8px;
    }
    
    .ad-container {
        max-width: 320px; /* Mobile banner width */
    }
    
    .ad-banner {
        min-height: 50px; /* Mobile banner height */
    }
}

@media (max-width: 480px) {
    .ad-section {
        margin: 24px 0;
        padding: 12px 4px;
    }
    
    .ad-container {
        max-width: 300px;
    }
}

/* Hide ads for Enterprise users */
.enterprise-user .ad-section {
    display: none !important;
}

/* Ensure ads don't interfere with content */
.ad-section + .section,
.ad-section + .hero-section,
.ad-section + .features-section {
    margin-top: 48px;
}

/* Loading state for ads */
.ad-loading {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    font-size: 12px;
    color: #999;
}

/* Improved ad visibility without being intrusive */
.adsbygoogle {
    display: block !important;
    margin: 0 auto;
    text-align: center;
}
.success-message { background: #e8f5e8; color: #2e7d32; padding: 16px; border-radius: 8px; margin: 16px 0; border: 1px solid #c8e6c9; font-size: 14px; }
.connected-status { background: #e8f5e8; border-color: #c8e6c9; }
.connected-status h3 { color: #2e7d32; }
.connected-status p { color: #2e7d32; }

/* Project Detail Specific Styles */
.project-info-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
    border: 1px solid #e5e5e7;
}

.project-header-detail {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.project-header-detail h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    color: #1d1d1f;
}

.project-meta-detail {
    display: flex;
    gap: 24px;
    color: #86868b;
    font-size: 14px;
    flex-wrap: wrap;
}

.project-meta-detail span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-meta-detail i {
    color: #007aff;
}

/* Override text input to be readonly in project detail */
.text-input-section textarea[readonly] {
    background: #f5f5f7;
    color: #515154;
    cursor: default;
}

.text-input-section textarea[readonly]:focus {
    outline: none;
    border-color: #e5e5e7;
}

/* Project detail specific button styling */
.project-detail .result-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .header-content { padding: 0 16px; }
    .app-title { font-size: 20px; }
    .main-content { padding: 24px 16px; }
    .quota-info { grid-template-columns: 1fr; }
    .plan-cards { grid-template-columns: 1fr; }
    .modal-content { padding: 24px 20px; }
}

@media (max-width: 480px) {
    .column-input { flex-direction: column; }
    .column-input input { min-width: auto; }
}

/* Text mode toggle */
.text-mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 5px;
    background: #f8f9fa;
    border-radius: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.toggle-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.toggle-btn.active {
    background: #007bff;
    color: white;
}

.toggle-btn.active:hover {
    background: #0056b3;
}

/* Text view containers */
#originalTextView, #newTextView {
    margin-bottom: 15px;
}

#originalTextView label, #newTextView label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

#originalTextArea {
    background-color: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
}

#newTextView .text-area {
    border: 2px solid #007bff;
    background-color: white;
}

/* Sheets Options Modal */
.sheets-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.option-card {
    padding: 20px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.option-card:hover {
    border-color: #007bff;
    background: #f8f9fa;
    transform: translateY(-2px);
}

.option-card.selected {
    border-color: #007bff;
    background: #e3f2fd;
}

.option-card i {
    font-size: 32px;
    color: #007bff;
    margin-bottom: 10px;
}

.option-card h3 {
    margin: 10px 0 8px 0;
    font-size: 16px;
    color: #2c3e50;
}

.option-card p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
}

#existingSheetsSelection {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

#existingSheetsSelection h4 {
    margin: 0 0 10px 0;
    color: #495057;
}

.form-select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .sheets-options {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .modal-actions {
        justify-content: center;
    }
}

/* Google Actions Styles */
.google-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.google-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.connected-status {
    text-align: left;
}

.disconnected-status {
    text-align: left;
}

.btn-outline-danger {
    background: transparent;
    border: 2px solid #dc3545;
    color: #dc3545;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

        .btn-outline-danger:hover {
            background: #dc3545;
            color: white;
        }
        
        /* Fix double outline issue - Comprehensive fix */
        *:focus {
            outline: none !important;
        }
        
        button:focus,
        input:focus,
        textarea:focus,
        select:focus,
        .btn:focus {
            outline: none !important;
            box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25) !important;
        }
        
        .nav-item:focus,
        a:focus {
            outline: none !important;
            box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.5) !important;
        }
        
        /* Remove any default browser outlines */
        input[type="text"]:focus,
        input[type="email"]:focus,
        input[type="password"]:focus,
        textarea:focus {
            outline: none !important;
            border: 1px solid #007aff !important;
            box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25) !important;
        }

.btn-success {
    background: #28a745;
    border: 2px solid #28a745;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-success:hover {
    background: #218838;
    border-color: #218838;
}

@media (max-width: 768px) {
    .google-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .google-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Loading Bar Styles */
.loading-bar-container {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e5e5e7;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: #e5e5e7;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #007aff, #0056cc);
    border-radius: 4px;
    animation: loadingProgress 2s ease-in-out infinite;
    transform: translateX(-100%);
}

@keyframes loadingProgress {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

.loading-text {
    margin: 0;
    font-size: 14px;
    color: #86868b;
    text-align: center;
}

/* Hide all modals in project detail page */
body[data-page="project-detail"] .subscription-modal,
body[data-page="project-detail"] #sheetsOptionsModal,
body[data-page="project-detail"] .modal {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}


