:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --excel-green: #107c41;
    --excel-green-hover: #0b5a30;
    --excel-green-light: #f0fdf4;
    --excel-green-border: #bbf7d0;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --table-header-bg: #f1f5f9;
    --table-row-hover: #f8fafc;
    --table-modified-bg: #f0fdf4;
    --table-saved-bg: #dcfce7;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ==========================================
   1. CLEAN HEADER & BRANDING
   ========================================== */
.app-header {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 12px;
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.excel-badge {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-title h1 span {
    color: var(--excel-green);
}

.brand-title .subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.user-status {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.user-status.connected {
    color: var(--excel-green);
    background: var(--excel-green-light);
    border-color: var(--excel-green-border);
}

#btn-install-app {
    height: 34px;
    padding: 0 12px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
    background: #f0fdf4;
    color: var(--excel-green-dark, #0d6535);
    border: 1px solid #bbf7d0;
    cursor: pointer;
    transition: all 0.2s ease;
}

#btn-install-app:hover {
    background: var(--excel-green, #107c41);
    color: #ffffff;
    border-color: var(--excel-green, #107c41);
}

/* ==========================================
   2. BUTTONS (Clean Excel Styling)
   ========================================== */
button {
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
}

.btn-excel-primary {
    background: var(--excel-green);
    color: #ffffff;
    border: 1px solid var(--excel-green);
    box-shadow: var(--shadow-sm);
}

.btn-excel-primary:hover:not(:disabled) {
    background: var(--excel-green-hover);
    border-color: var(--excel-green-hover);
}

.btn-excel-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-excel-secondary {
    background: #ffffff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-excel-secondary:hover:not(:disabled) {
    background: var(--table-header-bg);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-excel-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================
   3. SHEET TABS NAVIGATION
   ========================================== */
.nav-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 2px solid var(--border-color);
    padding-left: 4px;
}

.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-bottom: none;
    padding: 10px 18px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.tab-btn:hover {
    color: var(--excel-green);
    background: rgba(16, 124, 65, 0.05);
}

.tab-btn.active {
    background: var(--card-bg);
    color: var(--excel-green);
    border-color: var(--border-color);
    border-top: 3px solid var(--excel-green);
    box-shadow: var(--shadow-sm);
}

/* ==========================================
   4. UPLOAD & CONTROLS SECTION
   ========================================== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-section {
    background: var(--card-bg);
    border: 2px dashed var(--excel-green);
    border-radius: 10px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.upload-section:hover, .upload-section.dragover {
    background: var(--excel-green-light);
}

.upload-content {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

.upload-content strong {
    font-size: 0.95rem;
    color: var(--text-primary);
    display: block;
}

.upload-content p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.controls-section {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.search-bar {
    flex: 1;
    min-width: 220px;
}

.search-bar input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--excel-green);
    background: #ffffff;
}

.actions {
    display: flex;
    gap: 8px;
}

.filter-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.filter-grid input[type="text"],
.filter-grid input[type="date"],
.filter-grid .dropdown-btn,
.filter-grid .btn-excel-secondary,
.controls-section .btn-excel-primary {
    height: 36px;
    box-sizing: border-box;
    font-size: 0.84rem;
    line-height: 1.2;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    vertical-align: middle;
}

.filter-grid input[type="text"],
.filter-grid input[type="date"] {
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
    flex: 1 1 130px;
}

#filter-sheets-search {
    flex: 2 1 200px;
}

.filter-grid input:focus {
    border-color: var(--excel-green);
    background: #ffffff;
}

/* Checkbox Dropdown Filter (Coluna 3) */
.checkbox-dropdown-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 1 1 140px;
}

.dropdown-btn {
    gap: 8px;
    cursor: pointer;
    background: #ffffff;
    color: var(--text-primary);
    white-space: nowrap;
    width: 100%;
    justify-content: space-between;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    min-width: 240px;
    max-width: 320px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dropdown-header {
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.82rem;
}

.dropdown-header label, .chk-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.dropdown-options {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chk-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.chk-item:hover {
    background: var(--bg-color);
}

.chk-item label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chk-badge {
    font-size: 0.75rem;
    background: var(--table-header-bg);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* ==========================================
   5. CLEAN SPREADSHEET TABLE
   ========================================== */
.data-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.clean-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.clean-table thead {
    background-color: var(--table-header-bg);
}

.clean-table th {
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    font-size: 0.82rem;
    letter-spacing: 0.2px;
}

.clean-table th:last-child {
    border-right: none;
}

.clean-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    color: var(--text-primary);
}



.clean-table tbody tr:hover {
    background-color: var(--table-row-hover);
}

.clean-table tbody tr.modified-row {
    background-color: var(--table-modified-bg) !important;
}

.clean-table tbody tr.saved-row {
    background-color: var(--table-saved-bg) !important;
    transition: background 1s ease;
}

/* Inline Inputs in Table */
.inline-input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: all 0.15s;
}

.inline-input:hover {
    border-color: var(--border-hover);
    background: #ffffff;
}

.inline-input:focus {
    border-color: var(--excel-green);
    background: #ffffff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.2);
}

/* Status Message */
.status-msg {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--excel-green);
    min-height: 18px;
    padding-left: 4px;
}

.hidden {
    display: none !important;
}

/* Loading Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-left-color: var(--excel-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 8px;
}

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

#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
}

/* Modal Overlay & Form */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-content h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-subtitle {
    color: var(--excel-green);
    font-weight: 600;
    margin-top: -8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input, .form-group textarea {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
}

.form-group input:focus, .form-group textarea:focus {
    border-color: var(--excel-green);
    background: #ffffff;
}

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

/* Mobile Adjustments */
@media (max-width: 640px) {
    body {
        padding: 8px;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }
    .actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* ==========================================
   6. APP FOOTER & LEGAL LINKS
   ========================================== */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 10px;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--excel-green);
    text-decoration: underline;
}

/* ==========================================
   7. GOOGLE OAUTH COMPLIANCE INFO BANNER
   ========================================== */
.app-info-banner {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--excel-green);
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}

.info-content h2 {
    font-size: 1rem;
    color: var(--excel-green);
    margin-bottom: 6px;
}

.info-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 6px;
}

.compliance-note {
    font-size: 0.82rem !important;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.info-links {
    font-size: 0.82rem;
    margin-top: 8px;
}

.info-links a {
    color: var(--excel-green);
    font-weight: 600;
    text-decoration: none;
}

.info-links a:hover {
    text-decoration: underline;
}


