* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f3f3f3;
    color: #333;
}

/* TOP NAV BAR */
.top-nav {
    height: 52px;
    background-color: #ffffff;
    border-bottom: 1px solid #d1d1d1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 100;
}

.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* BUTTONS */
.circle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    transition: transform 0.1s, background-color 0.2s;
}

.circle-btn:hover {
    transform: scale(1.05);
}

.btn-files {
    background-color: #107c41; /* Excel Green */
}

.btn-ai {
    background-color: #1b6ec2; /* Gemini Blue */
}

.db-title-container {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 200px; 
    flex-shrink: 0;
}

.db-filename-display {
    font-size: 15px;
    font-weight: 600;
    padding: 4px 6px;
    color: #222;
    user-select: none;
    white-space: nowrap; 
}

.dirty-star {
    color: #d93025;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}


.hidden {
    display: none !important;
}

/* QUICK TOOLS */
.quick-tools {
    display: flex;
    gap: 2px;
}

.tool-btn {
    background: transparent;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
}

.tool-btn:hover {
    background-color: #eaeaea;
    color: #111;
}

/* SEARCH BAR */
.search-box-container {
    display: flex;
    align-items: center;
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 20px;
    padding: 4px 12px;
    width: 320px;
}

.search-icon {
    color: #5f6368;
    margin-right: 8px;
}

#search-input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 13px;
}

.scope-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    color: #5f6368;
}

/* --- MODAL OVERLAY & BACKDROP --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none !important;
}

/* --- SEARCH MODAL BOX --- */
.search-modal {
    background: #ffffff;
    width: 520px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    border: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f3f3f3;
    border-bottom: 1px solid #e0e0e0;
}

.search-modal-header h3 {
    margin: 0;
    font-size: 15px;
    color: #333;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
}

.search-modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Search Options Row (Match Case / Match Word) */
.search-options-row {
    display: flex;
    gap: 16px;
    padding: 0 2px;
}

.search-option-label {
    font-size: 12px;
    color: #444;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.search-option-label input[type="checkbox"] {
    cursor: pointer;
}

.scope-title {
    font-size: 12px;
    font-weight: bold;
    color: #555;
    margin-bottom: 6px;
    display: block;
}

.scope-columns {
    display: flex;
    gap: 12px;
}

.scope-box {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    height: 180px; /* Fixed height container */
    overflow: hidden;
}

.scope-box-header {
    padding: 6px 8px;
    background: #ededed;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

/* Both search-tables-list and search-cols-list scroll containers */
.scope-list,
#search-tables-list,
#search-cols-list {
    padding: 6px 8px;
    overflow-y: auto !important;
    max-height: 140px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.scope-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.table-tag {
    color: #64748b;
    font-size: 11px;
    font-weight: normal;
}

.search-match-status {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    text-align: right;
}

.search-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
}

.btn-search-nav {
    padding: 6px 14px;
    font-size: 12px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.btn-search-nav:hover:not(:disabled) {
    background: #eaf2ea;
    border-color: #107c41;
    color: #107c41;
}

.btn-search-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- SEARCH MATCH HIGHLIGHTS IN GRID --- */
mark.search-match {
    background-color: #b3d7ff !important;
    color: #000000 !important;
    border-radius: 2px;
    padding: 0 2px;
}

/* Currently Focused Active Match (Darker Blue) */
mark.search-match.active-match {
    background-color: #0078d4 !important;
    color: #ffffff !important;
    font-weight: bold;
}


/* MAIN LAYOUT */
.main-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* SIDEBARS */
.sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid #d1d1d1;
    display: flex;
    flex-direction: column;
    z-index: 90;
}


.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 14px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #888;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
}

.sidebar-menu li {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #444;
}

.sidebar-menu li:hover {
    background-color: #f0f0f0;
    color: #107c41;
}

/* ==========================================
   AI SIDEBAR (FIXED WIDTH)
   ========================================== */
.right-sidebar {
    width: 360px;
    min-width: 360px;
    max-width: 360px;
    background: #f8f9fa;
    border-left: 1px solid #d1d1d1;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
}

/* ==========================================
   AI CHAT MESSAGES & BUBBLES
   ========================================== */
.chat-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

/* Base Chat Bubble */
.chat-message {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.4;
    max-width: 80%;               /* Caps bubble width */
    width: fit-content;           /* Shrinks box snugly around text */
    text-align: left !important;  /* Force normal left-to-right text reading inside bubble */
    white-space: normal;          /* Allows clean standard text wrapping */
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    display: block;               /* Prevents inline/flex text distortion */
}

/* User Messages: Blueish background, aligned RIGHT */
.chat-message.user {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    background: #e8f0fe;
    color: #202124;
    border: 1px solid #d2e3fc;
    border-radius: 12px 12px 2px 12px;
    text-align: right;
    max-width: 80%;
}

/* AI / Bot Messages: White background, aligned LEFT */
.chat-message.bot,
.chat-message.ai {
    align-self: flex-start;
    margin-left: 0;
    margin-right: auto;
    background-color: #ffffff;
    color: #202124;
    border: 1px solid #e0e0e0;
    border-radius: 12px 12px 12px 2px;
    text-align: left;
    max-width: 85%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Confirmation Action Buttons Container */
.ai-confirmation-actions {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    align-self: flex-start;
}

.ai-confirmation-actions .btn {
    background-color: #ffffff;
    padding: 7px 15px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-confirmation-actions .btn-accept {
    border: 1px solid #28a745;
    color: #28a745;
}

.ai-confirmation-actions .btn-accept:hover {
    background-color: #28a745;
    color: #ffffff;
}

.ai-confirmation-actions .btn-cancel {
    border: 1px solid #dc3545;
    color: #dc3545;
}

.ai-confirmation-actions .btn-cancel:hover {
    background-color: #dc3545;
    color: #ffffff;
}

/* Include [contenteditable="true"] to match specificity */
#grid-body td.ai-highlight-duplicate,
#grid-body td[contenteditable="true"].ai-highlight-duplicate,
table td.ai-highlight-duplicate {
    background-color: #ffe8a1 !important;
    border-top: 1px solid #e6c200 !important;
    border-bottom: 1px solid #e6c200 !important;
}

/* Optional left accent bar on column A */
#grid-body td.ai-highlight-duplicate[data-col="0"] {
    border-left: 3px solid #f59e0b !important;
}

/* Missing cell audit highlight */
#grid-body td.ai-highlight-missing,
#grid-body td[contenteditable="true"].ai-highlight-missing {
    background-color: #f8d7da !important; /* Solid light red for high visibility */
    border: 1px dashed #dc3545 !important;
}

#grid-header th.ai-highlight-add,
#grid-body td.ai-highlight-add,
#grid-body td[contenteditable="true"].ai-highlight-add {
    background-color: #d4edda !important; /* Solid light green */
    border: 1px dashed #28a745 !important;
    color: #155724 !important;
}

/* Red preview for dropped column / duplicate row deletion (header + cells) */
#grid-header th.ai-highlight-remove,
#grid-body td.ai-highlight-remove,
#grid-body td[contenteditable="true"].ai-highlight-remove {
    background-color: #f8d7da !important; /* Solid light red */
    border-top: 1px dashed #dc3545 !important;
    border-bottom: 1px dashed #dc3545 !important;
    color: #721c24 !important;
    text-decoration: line-through !important;
}

#grid-body tr.row-0 td.row-0-cell.ai-highlight-remove,
#grid-body tr:first-child td.ai-highlight-remove {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border: 1px dashed #dc3545 !important;
}

/* Add left and right borders to the ends of highlighted rows */
#grid-body td.ai-highlight-remove:first-child {
    border-left: 2px solid #dc3545 !important;
}
#grid-body td.ai-highlight-remove:last-child {
    border-right: 2px solid #dc3545 !important;
}

/* Diff wrapper tags inside cells: [old] -> [new] */
.diff-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    white-space: nowrap;
}

.diff-old {
    background-color: rgba(220, 53, 69, 0.2);
    color: #a71d2a;
    border: 1px solid rgba(220, 53, 69, 0.4);
    border-radius: 3px;
    padding: 1px 5px;
    text-decoration: line-through;
}

.diff-arrow {
    color: #6c757d;
    font-weight: bold;
}

.diff-new {
    background-color: rgba(40, 167, 69, 0.2);
    color: #1e7e34;
    border: 1px solid rgba(40, 167, 69, 0.4);
    border-radius: 3px;
    padding: 1px 5px;
    font-weight: 600;
}

/* Preview tag for filled missing value: green badge + green border */
.fill-preview-badge {
    background-color: rgba(40, 167, 69, 0.15);
    color: #1e7e34;
    border: 1px dashed #28a745;
    border-radius: 3px;
    padding: 1px 6px;
    font-style: italic;
}

/* ==========================================
   CHAT INPUT AREA
   ========================================== */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    background: #ffffff;
    display: flex;
    gap: 8px;
    align-items: center;
}

#ai-input {
    flex: 1;
    height: 42px;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px;
    font-size: 13.5px;
    line-height: 1.4;
    resize: none;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

#ai-input:focus {
    border-color: #1b6ec2;
}

.send-btn {
    background: #1b6ec2;
    color: #ffffff;
    border: none;
    height: 42px;
    width: 42px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.send-btn:hover {
    background: #155799;
}

/* Disabled Chat Input Styling */
.chat-disabled,
input.chat-disabled,
button.chat-disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    background-color: #f1f5f9 !important; /* Slate light/grayed background */
    color: #94a3b8 !important;
}

/* ==========================================
   THINKING / TYPING ANIMATION (...)
   ========================================== */
.chat-message.thinking {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #1a73e8;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { 
        transform: scale(0.6);
        opacity: 0.4;
    } 
    40% { 
        transform: scale(1.1);
        opacity: 1;
    }
}

/* WORKSPACE & TABS */
.editor-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #e6e6e6;
}

/* Container for the Tab Bar + Pagination Controls */
.sheets-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 4px 12px;
    box-sizing: border-box;
}

/* Left Group: Dynamic Tabs & Add Button */
.tab-section-left {
    display: flex;
    align-items: center;
    overflow-x: auto;
    flex-grow: 1;
    margin-right: 16px;
}

.tabs-scroll-container {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
}

/* Right Group: Pagination Controls */
.pagination-container {
    display: flex;
    align-items: center;
    gap: 8px; 
    white-space: nowrap;
    user-select: none;
    background: #ffffff;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    padding: 4px 16px; 
    font-size: 14px; 
}

.page-btn {
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px; 
    font-weight: 700; 
    padding: 2px 6px;
    color: #333;
    line-height: 1;
    transition: opacity 0.15s ease;
}

.page-btn:hover {
    opacity: 0.6;
}

.page-btn:disabled {
    cursor: not-allowed;
    opacity: 0.25;
}

.page-indicator {
    font-size: 14px;
    font-weight: 600; 
    font-family: inherit;
    color: #222;
    padding: 0 6px;
}

/* Page number input field styling */
.page-input {
    width: 55px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0 6px;
    font-size: 14px;
    color: #222;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    background-color: transparent;
}

.tab {
    padding: 6px 16px;
    font-size: 13px;
    background: #e1e1e1;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab.active {
    background: #ffffff;
    border-top: 2px solid #107c41;
    font-weight: bold;
}

.add-tab-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    color: #107c41;
    margin-left: 4px;
}

/* --- GRID VIEWPORT & SCROLL CONTAINER --- */
.grid-viewport {
    flex: 1;
    overflow: auto !important;
    max-width: 100%;
    max-height: 100%;
    background: #fff;
    position: relative;
}

#grid-table {
    table-layout: auto;
    border-collapse: separate; /* Required for CSS sticky borders to render reliably */
    border-spacing: 0;
    width: max-content;
    background-color: #ffffff;
}

/* --- STICKY HEADERS --- */

/* 1. Sticky Column Headers (A, B, C...) */
#grid-header th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f3f3f3;
    color: #444;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid #c0c0c0;
    border-right: 1px solid #d0d7de;
    padding: 4px 8px;
    user-select: none;
    height: 26px;
    box-sizing: border-box;
}

/* 2. TOP-LEFT COORDINATE BOX (Sticky both Top and Left) */
#grid-header th#cell-coordinate-display {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 30 !important; /* Highest z-index so it floats above both top and left scrolls */
    background-color: #e4e4e4 !important;
    color: #107c41;
    font-weight: bold;
    font-size: 11px;
    font-family: monospace;
    text-align: center;
    border-right: 1px solid #c0c0c0;
    border-bottom: 1px solid #c0c0c0;
    min-width: 45px;
    height: 26px;
    box-sizing: border-box;
    vertical-align: middle;
}

/* 3. Sticky 0th Row (DB Column Schema Headers) */
#grid-body tr:first-child td {
    position: sticky;
    top: 26px; /* Below A-Z column headers */
    z-index: 9;
    background-color: #eaf2ea !important;
    font-weight: bold;
    border-bottom: 2px solid #b8d0b8 !important;
}

/* Sticky Row 0 Index Cell (Sticky both top: 26px and left: 0) */
#grid-body tr:first-child td.row-0 {
    position: sticky;
    top: 26px;
    left: 0;
    z-index: 25 !important;
    background-color: #d8e8d8 !important;
}

/* 4. Sticky Row Numbers Column (1, 2, 3...) */
#grid-body td.row-header {
    position: sticky;
    left: 0;
    z-index: 8;
    background-color: #f3f3f3;
    color: #666;
    font-size: 11px;
    text-align: center;
    border-right: 1px solid #c0c0c0;
    border-bottom: 1px solid #d0d7de;
    user-select: none;
    min-width: 45px;
    box-sizing: border-box;
}

/* --- ROW 0 SORTABLE BUTTON HEADERS --- */
#grid-body tr:first-child td.row-0-cell {
    position: sticky;
    top: 26px;
    z-index: 9;
    background-color: #eaf2ea !important;
    font-weight: bold;
    border-bottom: 2px solid #b8d0b8 !important;
    padding: 0; /* Clear padding so inner button spans full cell */
}

/* Flex container holding editable column text and sort indicator button */
.col-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 2px 4px 2px 8px;
}

.col-header-text {
    flex: 1;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sort Badge Button */
.btn-col-sort {
    background: transparent;
    border: none;
    color: #666;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    margin-left: 4px;
    border-radius: 3px;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.btn-col-sort:hover {
    background-color: #c8e0c8;
    color: #107c41;
}

.btn-col-sort.active-sort {
    background-color: #107c41;
    color: #ffffff;
    font-weight: bold;
}

/* 4. Top-Left Intersection Box (Coordinates Display: A1, B20, etc.) */
#cell-coordinate-display {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 20; /* Highest stack priority so it stays on top of both row and col scrolls */
    background-color: #e4e4e4 !important;
    color: #107c41;
    font-weight: bold;
    font-size: 11px;
    font-family: monospace;
    text-align: center;
    border-right: 1px solid #c0c0c0;
    border-bottom: 1px solid #c0c0c0;
    min-width: 45px;
    height: 26px;
    box-sizing: border-box;
    vertical-align: middle;
}

/* Sticky Intersection Box for Row 0 Label */
#grid-body td.row-0 {
    position: sticky;
    left: 0;
    z-index: 11;
    background-color: #d8e8d8 !important;
}

/* Default Unselected Cell State */
#grid-body td[contenteditable="true"] {
    min-width: 80px;
    max-width: 350px;
    height: 28px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    padding: 4px 8px;
    border: 1px solid #d0d7de;
    background-color: #ffffff !important;
    vertical-align: top;
}

/* Row Expansion when active/focused */
#grid-body tr.row-expanded {
    height: auto;
}

#grid-body tr.row-expanded td[contenteditable="true"] {
    white-space: pre-wrap;
    word-break: break-word;
    overflow: visible;
    text-overflow: clip;
}

/* --- EXCEL-STYLE SELECTION HIGHLIGHT --- */
#grid-body td.cell-selected {
    background-color: #f4f5f7 !important;
    border-color: #f4f5f7 !important;
    outline: none !important;
}

#grid-body td.cell-selected.sel-top {
    border-top: 2px solid #107c41 !important;
}
#grid-body td.cell-selected.sel-bottom {
    border-bottom: 2px solid #107c41 !important;
}
#grid-body td.cell-selected.sel-left {
    border-left: 2px solid #107c41 !important;
}
#grid-body td.cell-selected.sel-right {
    border-right: 2px solid #107c41 !important;
}

#grid-body td[contenteditable="true"]:focus {
    outline: 2px solid #107c41 !important;
    outline-offset: -2px;
}

.excel-table {
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

.excel-table th, .excel-table td {
    border: 1px solid #d4d4d4;
    min-width: 80px;
    max-width: 200px;
    height: 24px;
    padding: 2px 6px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    vertical-align: middle;
}

.excel-table th {
    background-color: #f3f3f3;
    color: #666;
    font-weight: normal;
    text-align: center;
    user-select: none;
}

/* Sub-string search highlighting */
mark.search-match {
    background-color: #0078d4;
    color: #ffffff;
    border-radius: 2px;
    padding: 0 1px;
}

/* CONTEXT MENU */
.context-menu {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-radius: 4px;
    z-index: 300;
    width: 120px;
}

.context-menu ul {
    list-style: none;
}

.context-menu li {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
}

.context-menu li:hover {
    background-color: #f0f0f0;
}

.context-menu li.danger {
    color: #d93025;
}

/* ==========================================
   TERMINAL WINDOW LAYOUT & CONTROLS
   ========================================== */
.logs-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.logs-modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.terminal-window {
    width: 780px;
    height: 460px;
    background-color: #0d0d0d; /* Pure dark body background */
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.terminal-window.maximized {
    width: 96vw !important;
    height: 92vh !important;
    border-radius: 6px;
}


/* Semi-Transparent Dark Gray Header Ribbon */
.terminal-header {
    height: 42px;
    background-color: rgba(35, 38, 45, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    user-select: none;
}

.terminal-title {
    color: #e0e0e0;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Transparent Background Top-Right Controls */
.win-btn {
    width: 32px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #a0a0a0;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.win-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.win-btn.close-btn:hover {
    background-color: #e81123;
    color: #ffffff;
}

/* Terminal / Execution Console Toggle Button */
#btn-logs-toggle {
    background-color: #d1d5db; 
    color: #1f2937;            
    border: 1px solid #9ca3af; 
    border-radius: 20px;       
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

#btn-logs-toggle:hover {
    background-color: #e5e7eb;
    border-color: #6b7280;
    color: #111827;
}

/* Active / Pressed state */
#btn-logs-toggle:active {
    background-color: #9ca3af;
}

/* ==========================================
   CONSOLE BODY & SYNTAX COLORING
   ========================================== */

.terminal-body {
    flex: 1;
    background-color: #0a0a0a;
    padding: 14px 18px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 12.5px;
    line-height: 1.6;
    color: #d4d4d4;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line {
    margin-bottom: 3px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-timestamp  { color: #6a9955; } /* Olive Sage Green */
.log-level-info { color: #569cd6; font-weight: 600; } /* Cyan Blue */
.sql-keyword    { color: #c586c0; } /* Purple Keyword */
.sql-table      { color: #4ec9b0; } /* Mint Teal for "Table" / "Column" */
.sql-string     { color: #ce9178; } /* Light Orange/Brown for 'strings' */
.sql-number     { color: #b5cea8; } /* Pale Green for numbers */
.system-msg     { color: #707070; font-style: italic; }