@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Flatseek Teal palette — Teal 800 (primary), Teal 900/950 (deep), Teal 50/100 (surface) */
  --primary: #115E59;
  --primary-light: #0F766E;
  --primary-dark: #134E4A;
  --accent: #115E59;
  --accent-light: rgba(17, 94, 89, 0.08);
  --success: #059669;
  --warning: #B45309;
  --danger: #EF4444;
  --bg-start: #F0FDFA;
  --bg-end: #CCFBF1;
  --surface: #FFFFFF;
  --surface-2: #F0FDFA;
  --surface-3: #CCFBF1;
  --border: #99F6E4;
  --text: #134E4A;
  --text-2: #115E59;
  --text-muted: #0D9488;
  --text-dim: #64748B;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 4px 14px rgba(13, 77, 68, 0.08), 0 2px 4px rgba(13, 77, 68, 0.04);
  --shadow-lg: 0 18px 48px rgba(13, 77, 68, 0.12), 0 4px 12px rgba(13, 77, 68, 0.06);
}
body { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
body > .header { flex-shrink: 0; }
body > .toolbar { flex-shrink: 0; }
body > .main-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Header — Teal 900 for all pages */
.header { background: #134E4A; border-bottom: 1px solid #042F2E; padding: 0 24px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; height: 60px; }
.header-left { display: flex; align-items: baseline; gap: 14px; }
.header .header-brand { color: #ffffff; background: none; -webkit-text-fill-color: #ffffff; font-size: 17px; font-weight: 700; }
.header .header-tagline { color: rgba(255,255,255,0.5); font-size: 12px; font-weight: 400; }
.header .header-subtitle { color: rgba(255,255,255,0.6); }
.header .nav-link { color: rgba(255,255,255,0.8); }
.header .nav-link:hover { color: #ffffff; background: rgba(255,255,255,0.1); }
.header .upload-btn { background: #ffffff; color: #115E59; }
.header .upload-btn:hover { background: #E5E5E5; }

/* Toolbar — Teal 600, darker than before */
.toolbar { background: #0D9488; border-bottom: 1px solid #134E4A; padding: 10px 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .index-selector { display: flex; align-items: center; gap: 6px; position: relative; }
.toolbar .index-selector label { font-size: 13px; color: rgba(255,255,255,0.75); font-weight: 500; }
.toolbar .search-box { position: relative; display: flex; flex: 1; max-width: 460px; gap: 6px; }
.toolbar .search-box input { flex: 1; padding: 8px 12px; border: 1px solid #0F766E; border-radius: 4px; font-size: 14px; background: #134E4A; color: #ffffff; }
.toolbar .search-box input::placeholder { color: rgba(255,255,255,0.4); }
.toolbar .search-box input:focus { outline: none; border-color: var(--primary); }
.toolbar .search-box button { padding: 8px 16px; background: #0F766E; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; font-weight: 500; }
.toolbar .search-box button:hover { background: #0D4D44; }
.toolbar .toolbar-actions { display: flex; align-items: center; gap: 6px; }
.toolbar .toolbar-actions label { font-size: 13px; color: rgba(255,255,255,0.75); font-weight: 500; }
.toolbar .toolbar-actions input { padding: 8px; border: 1px solid #134E4A; border-radius: 4px; width: 65px; font-size: 13px; background: #134E4A; color: #ffffff; }
.toolbar .secondary-btn { padding: 8px 14px; background: transparent; color: rgba(255,255,255,0.8); border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 500; }
.toolbar .secondary-btn:hover { background: rgba(255,255,255,0.12); color: #ffffff; }

.header-left { display: flex; align-items: center; gap: 32px; }
.dashboard-title { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.header-logo { width: 28px; height: 28px; transition: transform 0.2s; }
.dashboard-title:hover .header-logo { transform: scale(1.05); }
.header-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #115E59 0%, #0F766E 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.dashboard-title:hover .header-brand { filter: brightness(1.1); }
.header-subtitle { font-size: 14px; color: var(--text-muted); margin-left: 12px; font-weight: 500; }

.header-right { display: flex; align-items: center; gap: 12px; }
#cluster-status { font-size: 12px; padding: 8px 16px; border-radius: var(--radius); background: var(--success); color: white; font-weight: 600; }
#cluster-status.error { background: var(--danger); }
.nav-link { color: var(--text-2); text-decoration: none; font-size: 13px; padding: 6px 12px; border-radius: var(--radius); }
.nav-link:hover { color: var(--primary); background: var(--surface-2); }
.upload-btn { background: var(--primary); color: white; border: none; border-radius: var(--radius); padding: 8px 16px; font-size: 13px; font-weight: 600; transition: all 0.2s; }
#clear-query-btn { background: var(--danger); }
#clear-query-btn:hover { background: #E5334A; }
#clear-query-btn.hidden { display: none; }
.cluster-status-btn {
    color: white;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--success);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: 0.3px;
}
.cluster-status-btn:hover { background: #25A846; }
.cluster-status-btn.error { background: var(--danger); }
.hidden { display: none !important; }
.toolbar-actions { display: flex; align-items: center; gap: 6px; }
.toolbar-actions label { font-size: 13px; color: rgba(255,255,255,0.75); font-weight: 500; }
.toolbar-actions input { padding: 8px; border: 1px solid #134E4A; border-radius: 4px; width: 65px; font-size: 13px; background: #134E4A; color: #ffffff; }
.secondary-btn { padding: 8px 14px; background: transparent; color: rgba(255,255,255,0.8); border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 500; }

/* Custom Dropdown — opens downward */
.custom-dropdown { position: relative; display: inline-flex; }
.custom-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #134E4A;
    border: 1px solid #0D4D44;
    border-radius: 4px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    min-width: 140px;
    justify-content: space-between;
    transition: background 0.15s;
}
.custom-dropdown .dropdown-toggle:hover { background: #0D4D44; }
.custom-dropdown .dropdown-arrow { width: 10px; height: 6px; flex-shrink: 0; transition: transform 0.2s; }
.custom-dropdown.open .dropdown-arrow { transform: rotate(180deg); }
.custom-dropdown .dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: #ffffff;
    border: 1px solid #99F6E4;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(19, 78, 74, 0.2);
    z-index: 200;
    overflow: hidden;
    display: none;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
}
.custom-dropdown.open .dropdown-menu { display: flex; }
.custom-dropdown .dropdown-item {
    padding: 9px 14px;
    font-size: 13px;
    color: #134E4A;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s;
}
.custom-dropdown .dropdown-item:hover { background: rgba(17, 94, 89, 0.08); }
.custom-dropdown .dropdown-item.selected { background: rgba(17, 94, 89, 0.12); color: #115E59; font-weight: 600; }
.custom-dropdown .dropdown-item.empty { color: #94A3B8; font-style: italic; cursor: default; }
.custom-dropdown .dropdown-item.empty:hover { background: transparent; }
.secondary-btn:hover { background: rgba(255,255,255,0.12); color: #ffffff; }

/* Filter Tags */
.filter-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--primary); color: white; border-radius: var(--radius); font-size: 12px; cursor: pointer; font-weight: 500; }
.filter-tag.disabled { background: var(--text-muted); text-decoration: line-through; }
.filter-tag:hover { background: var(--primary-dark); }
.filter-tag.disabled:hover { background: #7A8898; }
.filter-tag .remove-tag { background: none; border: none; color: white; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; opacity: 0.7; }
.filter-tag .remove-tag:hover { opacity: 1; }
.filter-tag.disabled .remove-tag { color: white; }

/* Filter Popup */
.filter-popup { position: absolute; top: 100%; left: 0; margin-top: 6px; width: 480px; max-height: 70vh; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1000; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); }
.filter-popup.hidden { display: none; }
.filter-popup-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filter-popup-header h3 { font-size: 15px; color: var(--text); margin: 0; font-weight: 600; }
.close-popup { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 3px 6px; border-radius: var(--radius); }
.close-popup:hover { color: var(--text); background: var(--border); }
#filter-builder { padding: 14px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.filter-popup-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.filter-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.filter-item:hover { border-color: var(--primary-light); }
.filter-item-header { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-item select, .filter-item input[type="text"], .filter-item input[type="number"], .filter-item input[type="date"] { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.filter-item select:focus, .filter-item input:focus { border-color: var(--primary); outline: none; }
.filter-item .field-select { flex: 1; min-width: 100px; }
.filter-item .op-select { width: 90px; }
.filter-item .value-input { width: 100%; margin-top: 8px; }
.filter-item .remove-filter { background: var(--danger); color: white; border: none; border-radius: var(--radius); width: 26px; height: 26px; cursor: pointer; font-size: 16px; padding: 0; }
.filter-item .remove-filter:hover { background: #E5334A; }
.filter-range-inputs { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.filter-query-preview { margin-top: 12px; padding: 12px; background: var(--text); border-radius: var(--radius); }
.filter-query-preview label { font-size: 10px; color: #9CA3AF; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.filter-query-preview pre { color: #F9FAFB; font-size: 13px; margin-top: 6px; white-space: pre-wrap; word-break: break-all; font-family: 'JetBrains Mono', monospace; line-height: 1.5; }

/* Main Content */
.main-content { flex: 1; min-height: 0; padding: 14px 24px; display: flex; flex-direction: column; overflow: hidden; }

/* Stats tab — full viewport takeover, fixed header + footer */
#tab-stats {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 14px 24px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    overflow: auto;
}
#tab-stats .indices-stats-page {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 0;
    position: relative;
}

/* Stats totals */
#stats-totals {
    flex-shrink: 0;
    width: 100%;
    border-radius: 8px;
    margin: 0 0 14px 0;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #0D9488 0%, #0F766E 50%, #14B8A6 100%);
    box-shadow: 0 2px 12px rgba(13, 148, 136, 0.25);
}

/* Stats table — scrollable body, sticky header */
.stats-table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
}
.stats-table-wrap.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(240, 253, 250, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 30;
    border-radius: 8px;
}
.stats-table-wrap.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 31;
}
#stats-cards { width: 100%; }
/* Stats page full loading overlay */
.indices-stats-loading {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(240, 253, 250, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
}
.indices-stats-loading .loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--surface-3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.indices-stats-loading .loading-text {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stats-pagination-wrap {
    flex-shrink: 0;
    padding: 16px 0 8px;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Tabs with inline agg toolbar */
#main-tabs { display: flex; align-items: center; gap: 3px; margin-bottom: 0; background: var(--surface-2); padding: 4px; border-radius: var(--radius) var(--radius) 0 0; }
#main-tabs .tab { padding: 9px 18px; background: transparent; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-2); transition: all 0.15s; }
#main-tabs .tab:hover { color: var(--primary); background: var(--surface); }
#main-tabs .tab.active { background: var(--primary); color: white; }

/* Map Tab */
#map-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface-2); border-radius: var(--radius); margin-bottom: 14px; }
.map-field-selects { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.map-field-selects select { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; min-width: 150px; }
#map-combined-field { display: none; }
#map-combined-field.visible { display: block; }
.map-size-input { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); margin-left: 8px; }
.map-size-input input { width: 70px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
#map-status { margin-left: auto; color: var(--text-muted); font-size: 12px; }
#map-container { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
#map-placeholder { background: var(--surface-2); border: 2px dashed var(--border); border-radius: var(--radius); margin-top: 18px; padding: 50px; text-align: center; color: var(--text-muted); }

/* Agg Pagination */
.agg-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; margin-top: 14px; }
.agg-pagination button { padding: 7px 14px; background: var(--primary); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; }
.agg-pagination button:hover:not(:disabled) { background: var(--primary-dark); }
.agg-pagination button:disabled { background: var(--text-muted); cursor: not-allowed; }
.agg-pagination span { font-size: 13px; color: var(--text-muted); }

/* Content Area */
.content { min-width: 0; overflow: hidden; background: var(--surface); border-radius: var(--radius); margin: 0; height: 100%; border: 1px solid var(--border); display: flex; flex-direction: column; }
.tab-content { display: none; background: var(--surface); padding: 18px; min-height: 350px; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; }

/* Search / Results area — toolbar fixed top, table scrolls, pagination fixed bottom */
#tab-results { display: none; }
#tab-results.active { display: flex; }
#tab-results .results-info { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; padding: 0 0 12px 0; }
#tab-results .results-info > span:first-child { font-weight: 600; color: var(--text); }
#tab-results .results-meta { color: var(--text-dim); font-size: 12px; }
#tab-results .dedup-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#tab-results .dedup-controls label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
#tab-results .dedup-controls select { margin-left: 4px; }
#tab-results .dedup-controls select.hidden { display: none; }
#tab-results .search-chart-container { margin-bottom: 12px; }
#results-table-wrap { flex: 1; overflow: auto; position: relative; min-height: 0; }
#results-table-wrap #loading-overlay {
    position: sticky;
    top: 0; left: 0; right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 60px 0;
}
#results-table-wrap #loading-overlay.hidden { display: none; }
#results-table { overflow: visible; border: 1px solid var(--border); border-radius: var(--radius); }
#results-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
#results-table th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; white-space: nowrap; color: var(--text); z-index: 10; box-shadow: 0 1px 0 var(--border); }
#results-table th.row-num { width: 45px; text-align: center; color: var(--text-muted); font-size: 11px; }
#results-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); background: var(--surface); }
#results-table tr:hover td { background: var(--surface-2); }
#results-table tr.doc-row:hover td { background: #CCFBF1; }
#results-table td.row-num { text-align: center; color: var(--text-muted); font-size: 11px; }
#results-table .expand-icon { font-size: 10px; margin-right: 4px; color: var(--primary); }
#results-table .doc-detail td { padding: 12px; background: var(--surface-2); }
#results-table .doc-detail pre { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; font-family: monospace; background: var(--surface); padding: 8px; border-radius: 4px; max-height: 300px; overflow-y: auto; }
#tab-results .pagination { margin-top: 16px; display: flex; align-items: center; gap: 10px; justify-content: center; flex-shrink: 0; }

/* Aggregation & Map tabs */
#tab-aggregations, #tab-map { overflow: hidden; }
#tab-aggregations.active, #tab-map.active { display: flex; flex-direction: column; }
#tab-aggregations .agg-form-row, #tab-map .map-toolbar { flex-shrink: 0; }
#agg-scroll-wrap { flex: 1; overflow: auto; min-height: 0; display: flex; flex-direction: column; }

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.loading-overlay.hidden { display: none; }
.loading-overlay .loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Search Chart - hidden by default, only show when has date data */
.search-chart-container { display: none; }
.search-chart-container.visible { display: block; margin-bottom: 18px; background: var(--surface-2); border-radius: var(--radius); padding: 14px; max-height: 300px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chart-title { font-weight: 600; font-size: 13px; color: var(--text); }
.search-chart-container canvas { display: block; width: 100%; height: 220px; }
.date-range-filter { display: flex; align-items: center; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.date-range-filter label { color: var(--text-muted); }
.date-range-filter input { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; }
.date-range-filter select { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; background: var(--surface); }
#chart-field-select { font-weight: 600; color: var(--primary); min-width: 120px; }
.chart-toggle-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 3px 7px; cursor: pointer; font-size: 11px; color: var(--text-muted); line-height: 1; }
.chart-toggle-btn:hover { background: var(--surface-2); color: var(--text); }
.chart-toggle-btn.collapsed { color: var(--primary); }
.search-chart-container.chart-collapsed { padding: 8px 14px; }

/* Results Table */
#results-table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-row { cursor: pointer; }
.doc-row:hover { background: #CCFBF1; }
.expand-icon { font-size: 10px; margin-right: 4px; color: var(--primary); }
.doc-detail { background: var(--surface-2); }
.doc-detail td { padding: 12px; }
.doc-detail pre { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; font-family: monospace; background: var(--surface); padding: 8px; border-radius: 4px; max-height: 300px; overflow-y: auto; }

/* Data Cell with Filter */
.data-cell { position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.data-cell.empty-cell { color: var(--text-muted); font-style: italic; }
.cell-filter { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); background: var(--primary); color: white; border: none; border-radius: 2px; width: 20px; height: 20px; cursor: pointer; font-size: 11px; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; }
.data-cell:hover .cell-filter { opacity: 1; }
.cell-filter:hover { background: var(--primary-dark); }

/* Dot-path (nested object) columns */
th.dot-field { color: #115E59; }
td.data-cell.dot-field { color: #115E59; font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* Table Header Hide Button */
th { position: relative; }
.th-content { margin-right: 20px; }
.hide-col-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #99F6E4; cursor: pointer; font-size: 14px; opacity: 0; transition: opacity 0.15s; padding: 3px 5px; border-radius: 2px; }
th:hover .hide-col-btn { opacity: 1; }
.hide-col-btn:hover { background: var(--danger); color: white; }

/* Hidden Column Tags */
.hidden-columns-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hidden-col-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: var(--warning); color: white; border-radius: var(--radius); font-size: 11px; font-weight: 500; }
.show-col-btn { background: none; border: none; color: white; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; opacity: 0.7; }
.show-col-btn:hover { opacity: 1; }

/* Pagination */
.pagination { margin-top: 20px; display: flex; align-items: center; gap: 10px; justify-content: center; }
.pagination button { padding: 8px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; }
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination button.page-btn { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button.page-btn:hover:not(:disabled) { background: var(--primary-dark); }
.pagination-info { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }

/* Aggregation */
#agg-scroll-wrap { display: flex; gap: 20px; flex-direction: column; flex: 1; min-height: 0; }
#agg-chart-container { display: block; width: 100%; height: 320px; margin: 0 auto 16px; }
#agg-scroll-wrap.view-chart #agg-chart-container { height: 400px; display: block; }
#agg-results { flex: 1; min-width: 0; }
#agg-results table { margin-top: 10px; width: 100%; border-collapse: collapse; font-size: 13px; }
#agg-results th, #agg-results td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
#agg-results th { background: var(--surface-2); font-weight: 600; }
#agg-results .agg-key { font-weight: 500; }
#agg-results .agg-count { color: var(--primary); font-weight: 600; }
#agg-results .agg-pct { color: var(--text-muted); font-size: 11px; }
#agg-scroll-wrap.view-chart #agg-chart-container { flex: none; }
#agg-scroll-wrap.view-chart #agg-results { display: none; }
#agg-scroll-wrap.view-table #agg-chart-container { display: none; }
#agg-scroll-wrap.view-table #agg-results { flex: 1; }

/* Stats Table */
/* #stats-totals styles already defined above */
#stats-totals .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 20px;
    border-right: 1px solid rgba(255,255,255,0.1);
    flex: 1;
}
#stats-totals .stat-item:last-child { border-right: none; }
#stats-totals .stat-label {
    font-size: 9px;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 600;
}
#stats-totals .stat-value {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
#stats-refresh-btn {
    position: relative;
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 14px;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
#stats-refresh-btn:hover {
    background: rgba(255,255,255,0.35);
    border-color: rgba(255,255,255,0.5);
}
/* Stats table — sticky header, scrollable body */
.stats-table { width: 100%; border-collapse: collapse; border-radius: 8px; }
.stats-table thead { position: sticky; top: 0; z-index: 10; }
.stats-table th { text-align: left; padding: 10px 14px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.75); font-weight: 600; border-bottom: 2px solid #042F2E; background: #0D4D44; box-shadow: 0 2px 0 rgba(0,0,0,0.15); }
.stats-table td { padding: 10px 14px; background: var(--surface); font-size: 13px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.stats-table tr:hover td { background: var(--surface-2); }
.stats-table tr[data-index]:hover td { cursor: default; }
.stats-table .index-name-cell { font-weight: 700; color: var(--text); }
.stats-table .actions-cell { display: flex; gap: 5px; align-items: center; }
.stats-table .actions-cell button { padding: 5px 12px; font-size: 12px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; transition: all 0.15s; }
.stats-table .status-cell .status-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.stats-table .status-badge.running { background: rgba(17, 94, 89, 0.15); color: #115E59; }
.stats-table .status-badge.upload { background: rgba(59, 130, 246, 0.15); color: #1e3a8a; }
.stats-table .status-badge.interrupted { background: rgba(220, 38, 38, 0.12); color: #991B1B; }
.stats-table .status-badge.done { background: rgba(5, 150, 105, 0.12); color: #065F46; }
.stats-table .docs-cell, .stats-table .size-cell, .stats-table .cols-cell { text-align: center; }
.stats-table .encrypted-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: rgba(17, 94, 89, 0.12); color: #115E59; border-radius: 4px; font-size: 11px; font-weight: 700; border: 1px solid rgba(17, 94, 89, 0.2); white-space: nowrap; }
.stats-table .default-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: rgba(59, 130, 246, 0.12); color: #1e3a8a; border-radius: 4px; font-size: 11px; font-weight: 700; border: 1px solid rgba(59, 130, 246, 0.2); white-space: nowrap; }
.stats-table .set-default-btn { font-size: 11px; padding: 4px 10px; border-radius: 6px; background: rgba(17, 94, 89, 0.15); border: 1px solid rgba(17, 94, 89, 0.3); color: #115E59; cursor: pointer; font-weight: 600; transition: all 0.15s; }
.stats-table .set-default-btn:hover { background: #115E59; color: #ffffff; }
.stats-table .encrypt-btn { background: rgba(17, 94, 89, 0.15); color: #115E59; border: 1px solid rgba(17, 94, 89, 0.3); }
.stats-table .encrypt-btn:hover { background: #115E59; color: #fff; }
.stats-table .decrypt-btn { background: rgba(17, 94, 89, 0.15); color: #115E59; border: 1px solid rgba(17, 94, 89, 0.3); }
.stats-table .decrypt-btn:hover { background: #115E59; color: #fff; }
.stats-table .delete-btn { background: #DC2626; color: #ffffff; border: 1px solid #DC2626; }
.stats-table .delete-btn:hover { background: #B91C1C; border-color: #B91C1C; }
.stats-table .stats-action-btn { background: rgba(17, 94, 89, 0.15); color: #115E59; border: 1px solid rgba(17, 94, 89, 0.3); font-size: 11px; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; transition: all 0.15s; }
.stats-table .stats-action-btn:hover { background: #115E59; color: #ffffff; }
.stats-table .rename-btn { background: rgba(17, 94, 89, 0.15); color: #ffffff; border: 1px solid rgba(17, 94, 89, 0.3); font-size: 11px; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; transition: all 0.15s; }
.stats-table .rename-btn:hover { background: #115E59; }
.stats-table .stats-pagination-wrap { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px 0; }
.stats-table .page-btn { min-width: 34px; height: 34px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.stats-table .page-btn:hover { border-color: var(--primary); color: var(--primary); }
.stats-table .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.stats-table .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stats-table .page-ellipsis { color: var(--text-muted); font-size: 14px; padding: 0 4px; }
.stats-table .page-info { font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(26,35,50,0.5); backdrop-filter: blur(2px); align-items: center; justify-content: center; }
.modal-content { background: var(--surface); margin: 50px auto; padding: 24px; border-radius: var(--radius); width: 90%; max-width: 780px; max-height: 85vh; overflow: auto; position: relative; box-shadow: var(--shadow-lg); }
.modal-content.upload-modal-content { max-width: 660px; }
.modal-content.upload-modal-content.wide { max-width: 960px; }
.modal h2 { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 18px; }
.close { position: absolute; right: 18px; top: 16px; font-size: 24px; cursor: pointer; color: var(--text-muted); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); }
.close:hover { color: var(--text); background: var(--surface-2); }
.modal-content pre { background: var(--surface-2); padding: 14px; border-radius: var(--radius); font-size: 13px; overflow-x: auto; }
.doc-modal-content { max-width: 700px; }
.doc-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.doc-modal-header h2 { font-size: 17px; color: var(--text); }
#doc-modal-body { max-height: 58vh; overflow-y: auto; }
#doc-modal-body pre { background: var(--text); color: #F9FAFB; padding: 18px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
#doc-modal-body .json-key { color: #60A5FA; }
#doc-modal-body .json-string { color: #34D399; }
#doc-modal-body .json-number { color: #0F766E; }
#doc-modal-body .json-boolean { color: #A78BFA; }
#doc-modal-body .json-null { color: #9CA3AF; }
.copy-success { background: var(--success) !important; color: white !important; }

/* Debug Bar */
.debug-bar { display: none; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 18px; max-height: 180px; overflow-y: auto; font-size: 11px; }
.debug-bar.visible { display: block; }
.debug-bar .debug-section { display: flex; gap: 20px; }
.debug-label { font-weight: 600; color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }
.debug-section pre { margin: 0; white-space: pre-wrap; word-break: break-all; color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 11px; max-height: 140px; overflow-y: auto; background: var(--surface-2); padding: 8px; border-radius: var(--radius); }
.debug-toggle { position: fixed; bottom: 14px; right: 14px; background: var(--text); color: #fff; border: none; padding: 7px 12px; border-radius: var(--radius); cursor: pointer; font-size: 11px; font-weight: 500; z-index: 1001; }
.debug-toggle:hover { background: #2D3748; }

/* Buttons */
button { font-size: 13px; cursor: pointer; font-family: inherit; }
.small-btn { padding: 6px 12px; background: var(--text-muted); color: white; border: none; border-radius: var(--radius); font-weight: 500; }
.small-btn:hover { background: #7A8898; }
.primary-btn { padding: 10px 20px; background: var(--primary); color: white; border: none; border-radius: var(--radius); font-weight: 600; transition: all 0.2s; }
.primary-btn:hover:not(:disabled) { background: var(--primary-dark); }
.primary-btn:disabled { background: var(--text-muted); cursor: not-allowed; }
.secondary-btn { background: var(--surface); color: var(--primary); border: 1px solid var(--primary); }
.secondary-btn:hover { background: var(--surface-2); }

/* Upload Modal */
.error-detail-item { background: #FEF2F2; border-left: 3px solid var(--danger); padding: 12px; margin: 8px 0; border-radius: var(--radius); }
.error-detail-item pre { background: var(--text); color: #F9FAFB; padding: 10px; border-radius: var(--radius); font-size: 12px; margin-bottom: 8px; overflow-x: auto; }
.error-detail-item .error-reason { color: var(--danger); font-size: 12px; font-weight: 500; }
.error-summary { background: #FEF2F2; border: 1px solid #FECACA; border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.error-summary strong { color: var(--danger); }
.error-count { color: var(--danger); font-size: 13px; font-weight: 600; margin-top: 8px; }

.upload-dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 48px 32px; text-align: center; background: var(--surface-2); cursor: pointer; transition: all 0.2s; }
.upload-dropzone:hover { border-color: var(--primary); background: rgba(17, 94, 89, 0.08); }
.upload-dropzone.dragover { border-color: var(--success); background: rgba(17, 94, 89, 0.12); }
.upload-dropzone p { color: var(--text); margin-bottom: 12px; font-size: 14px; font-weight: 500; }
.upload-dropzone .hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.upload-dropzone input[type="file"] { display: none; }
#browse-btn { margin-top: 14px; }
.upload-progress { margin-top: 18px; padding: 18px; background: var(--surface-2); border-radius: var(--radius); }
.upload-progress .progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.upload-progress .progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: 4px; transition: width 0.3s ease-out; }
.upload-progress .progress-text { font-size: 13px; color: var(--text); font-weight: 500; margin-bottom: 6px; }
.upload-progress .progress-file { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.sheet-btn {
    padding: 5px 14px;
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.08);
    color: #1D4ED8;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.sheet-btn:hover { background: rgba(59, 130, 246, 0.2); }
.sheet-btn.active {
    background: #1D4ED8;
    color: #fff;
    border-color: #1D4ED8;
}
.success-msg { background: linear-gradient(135deg, rgba(17, 94, 89, 0.08), rgba(17, 94, 89, 0.05)); border: 1px solid #99F6E4; color: #134E4A; padding: 14px 20px; border-radius: var(--radius); margin-top: 10px; font-size: 14px; text-align: center; }
.success-msg strong { font-size: 16px; }
.upload-step { margin-bottom: 26px; }
.upload-step.hidden { display: none; }
.step-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.step-header h3 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; color: var(--text); }
.step-num { width: 28px; height: 28px; background: var(--primary); color: white; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.hint { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.step-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; }
.file-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; padding: 14px; background: var(--surface-2); border-radius: var(--radius); }
.file-meta-item { display: flex; flex-direction: column; padding: 6px; }
.file-meta-item .label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.file-meta-item .value { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 3px; }
.format-info { padding: 12px 18px; background: var(--surface-2); border-radius: var(--radius); font-size: 14px; font-weight: 500; }
.format-info .badge { display: inline-block; padding: 3px 10px; background: var(--primary); color: white; border-radius: var(--radius); font-size: 11px; margin-left: 10px; font-weight: 600; }
.table-scroll { overflow-x: auto; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.mapping-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mapping-table th { background: var(--surface-2); padding: 10px; text-align: left; border-bottom: 1px solid var(--border); position: sticky; top: 0; font-weight: 600; }
.mapping-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.mapping-table tr:hover td { background: var(--surface-2); }
.mapping-table .col-name { font-weight: 500; }
.mapping-table .type-badge { padding: 3px 10px; border-radius: var(--radius); font-size: 11px; background: rgba(17, 94, 89, 0.08); color: #115E59; cursor: pointer; font-weight: 500; }
.mapping-table .type-badge:hover { background: var(--primary); color: white; }
.mapping-table .type-badge.high { background: rgba(17, 94, 89, 0.08); color: #059669; }
.mapping-table .type-badge.high:hover { background: #059669; color: white; }
.mapping-table .sample-values { font-size: 12px; color: var(--text-muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-table tr.clickable { cursor: pointer; }
.mapping-table tr.clickable:hover { background: rgba(17, 94, 89, 0.06); }
.mapping-table tr.excluded-row td { opacity: 0.5; background: var(--surface); }
.mapping-table tr.excluded-row .col-name { text-decoration: line-through; }
.mapping-table .insert-as-input { border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; background: white; }
.mapping-table .insert-as-input:focus { border-color: var(--primary); outline: none; }
.mapping-table .exclude-col-checkbox { cursor: pointer; width: 16px; height: 16px; }
.preview-section { margin-bottom: 22px; }
.preview-section h4 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.sample-values { padding: 10px; background: var(--surface-2); border-radius: var(--radius); font-size: 13px; max-height: 90px; overflow-y: auto; }
.sample-values .sample-item { padding: 3px 8px; background: var(--surface); border-radius: var(--radius); margin: 3px 3px 3px 0; display: inline-block; font-size: 12px; }
.upload-summary { text-align: center; padding: 28px; }
.upload-summary .big-number { font-size: 48px; font-weight: 700; color: var(--success); }
.upload-summary .label { font-size: 15px; color: var(--text-muted); margin-top: 6px; }
.file-info { margin-top: 14px; padding: 12px 16px; background: var(--surface-2); border-radius: var(--radius); font-size: 14px; border-left: 3px solid var(--primary); }
.file-info .filename { font-weight: 600; color: var(--text); }
.file-info .filesize { color: var(--text-muted); }
.headers-history-list { max-height: 120px; overflow-y: auto; border-radius: var(--radius); }
.headers-history-item { padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius); margin-bottom: 4px; cursor: pointer; font-size: 12px; font-family: monospace; }
.headers-history-item:hover { background: var(--primary); color: white; }
.headers-history-item .history-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.headers-history-item:hover .history-label { color: rgba(255,255,255,0.8); }

/* Form */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text); margin-bottom: 5px; font-weight: 500; }
.form-group input[type="text"], .form-group input[type="password"], .form-group textarea, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--primary); }
.form-group textarea { min-height: 70px; font-family: 'JetBrains Mono', monospace; resize: vertical; }

/* Indices Page */
#indices-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
#indices-list { display: flex; flex-direction: column; gap: 14px; }
.indices-count-header { display: flex; align-items: center; gap: 16px; }
.indices-badge { display: inline-flex; align-items: center; padding: 8px 16px; background: rgba(255,255,255,0.2); border-radius: var(--radius); font-size: 15px; font-weight: 600; color: white; }
.loading-text { font-size: 14px; color: rgba(255,255,255,0.7); }
.indices-list-loading { display: flex; justify-content: center; padding: 40px; }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.indices-totals { display: flex; gap: 28px; padding: 22px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-radius: var(--radius); margin-bottom: 22px; }
.indices-totals.loading { justify-content: space-between; align-items: center; }
.total-stat { text-align: center; }
.total-stat .label { font-size: 11px; color: rgba(255,255,255,0.8); text-transform: uppercase; letter-spacing: 0.5px; }
.total-stat .value { font-size: 26px; font-weight: 700; color: white; margin-top: 4px; }
.index-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: all 0.2s; }
.index-card:hover { border-color: var(--primary); }
.index-card.selected { border-color: var(--primary); background: rgba(17, 94, 89, 0.08); }
.index-card.default { border-color: var(--primary); box-shadow: 0 0 0 2px var(--accent-light); }
.index-card-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.index-card-name { font-size: 18px; font-weight: 700; color: var(--text); flex: 1; }
.default-badge { display: inline-flex; align-items: center; padding: 4px 10px; background: var(--accent); color: white; border-radius: var(--radius); font-size: 12px; font-weight: 600; }
.set-default-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 4px 10px; border-radius: var(--radius); font-size: 12px; cursor: pointer; transition: all 0.15s; }
.set-default-btn:hover { border-color: var(--primary); color: var(--primary); }
.index-card-actions { display: flex; gap: 8px; margin-left: auto; }
.index-card-actions button { padding: 6px 12px; font-size: 12px; border-radius: var(--radius); border: none; cursor: pointer; }
.index-card-actions .delete-btn { background: var(--danger); color: white; }
.index-card-actions .delete-btn:hover { background: #E5334A; }
.index-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.index-stat { background: var(--surface-2); padding: 12px; border-radius: var(--radius); text-align: center; }
.index-stat .label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.index-stat .value { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 4px; }
.index-stat .value.bytes { font-size: 13px; }
.index-card-columns { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.index-card-columns h4 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.5px; }
.column-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.column-tag { display: inline-block; padding: 4px 10px; background: var(--surface-2); border-radius: var(--radius); font-size: 12px; color: var(--text); }
.column-tag.name { background: rgba(17, 94, 89, 0.08); color: #059669; }
.column-tag.email { background: rgba(17, 94, 89, 0.08); color: #115E59; }
.column-tag.phone { background: rgba(17, 94, 89, 0.08); color: #115E59; }
.column-tag.date { background: rgba(17, 94, 89, 0.08); color: #115E59; }
.column-tag.gender { background: rgba(17, 94, 89, 0.08); color: #115E59; }
.column-tag.city { background: rgba(17, 94, 89, 0.08); color: #115E59; }
.column-tag.number { background: rgba(17, 94, 89, 0.08); color: #0F766E; }
.index-card-mapping { margin-top: 10px; padding: 10px; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }
.index-card-mapping .mapping-content { font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 180px; overflow: auto; }
.indices-mapping-section { margin-top: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.indices-mapping-section.hidden { display: none; }
.indices-mapping-section .mapping-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.indices-mapping-section .mapping-header h3 { font-size: 14px; color: var(--text); margin: 0; font-weight: 600; }
.indices-mapping-section pre { font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: var(--radius); overflow: auto; max-height: 380px; }

/* Index card action progress overlay */
.index-card-action-overlay {
    position: absolute;
    inset: 0;
    background: rgba(248, 249, 250, 0.85);
    backdrop-filter: blur(4px);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 10;
}
.index-card-action-overlay .progress-bar {
    width: 80%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.index-card-action-overlay .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.2s ease-out;
}
.index-card-action-overlay .progress-text {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}
.index-card-action-overlay .progress-text.error {
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    background: rgba(254, 226, 226, 0.95);
    border: 1px solid #FECACA;
    border-radius: 6px;
    padding: 8px 14px;
    width: 90%;
    text-align: center;
}

/* Encrypted badge */
.encrypted-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(17, 94, 89, 0.12);
    color: #115E59;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
}
.encrypted-badge svg { width: 12px; height: 12px; }

/* Password modal for encrypted index */
#password-modal .modal-content { max-width: 400px; }
.password-modal-body { padding: 14px 0; }
.password-modal-body .form-group { margin-bottom: 14px; }
.password-modal-body .error-msg { margin-top: 8px; }

/* Agg Form Row in tab */
.agg-form-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); flex-wrap: wrap; }
.agg-form { display: flex; align-items: center; gap: 6px; }
.agg-form select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; background: var(--surface); cursor: pointer; }
.agg-form input { padding: 7px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; width: 55px; }
.agg-form .primary-btn.small { padding: 7px 14px; font-size: 12px; }
.agg-form-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.agg-type-toggle { display: flex; gap: 3px; }
.agg-type-toggle .type-btn { padding: 5px 10px; background: transparent; border: 1px solid rgba(13, 148, 136, 0.4); border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text-2); transition: all 0.15s; }
.agg-type-toggle .type-btn:hover { border-color: var(--primary); color: var(--primary); background: rgba(13, 148, 136, 0.05); }
.agg-type-toggle .type-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.agg-view-toggle { display: flex; gap: 3px; }
.view-btn { padding: 5px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text-2); transition: all 0.15s; }
.view-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.view-btn.active { background: var(--primary-dark); color: white; border-color: var(--primary-dark); }

/* Utilities */
.loading { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.error-msg { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger); padding: 14px; border-radius: var(--radius); margin: 18px 0; }
#toggle-columns-btn { padding: 6px 12px; font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
#toggle-columns-btn:hover { border-color: var(--primary); color: var(--primary); }
.column-selector { position: absolute; top: 100%; left: 0; margin-top: 6px; width: 220px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1000; border: 1px solid var(--border); }
.column-selector.hidden { display: none; }
.column-selector-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; color: var(--text); }
.column-selector-header .close-popup { font-size: 20px; padding: 0; }
#column-list { padding: 10px; max-height: 300px; overflow-y: auto; }
.column-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.column-item:hover { background: var(--surface-2); }
.column-item input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.column-item.included { color: var(--success); font-weight: 500; }
.column-item.excluded { color: var(--text-muted); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #E0F2F0; }
::-webkit-scrollbar-thumb { background: #99F6E4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #0D9488; }

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  /* Header */
  .header { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .header-left { gap: 12px; }
  .header-right { gap: 8px; }
  .header-subtitle { display: none; }
  .nav-link { display: none; }
  .upload-btn { padding: 7px 12px; font-size: 12px; }

  /* Toolbar */
  .toolbar { padding: 10px 16px; flex-direction: column; align-items: stretch; gap: 8px; }
  .index-selector { width: 100%; }
  .index-selector select { flex: 1; }
  .search-box { max-width: 100%; }
  .toolbar-actions { flex-wrap: wrap; }

  /* Tabs */
  #main-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 3px; }
  #main-tabs .tab { padding: 8px 14px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }

  /* Main content */
  .main-content { flex: 1; min-height: 200px; padding: 10px 16px; overflow: visible; }
  .content { height: auto; min-height: 300px; overflow: visible; }

  /* Results table */
  #tab-results { overflow: hidden; }
  #results-table-wrap { max-height: 60vh; }

  /* Stats tab */
  #tab-stats { padding: 10px 16px; top: 60px; overflow: auto; display: flex; flex-direction: column; }
  #stats-totals { flex-wrap: wrap; gap: 8px; padding: 8px; position: relative; }
  .stats-table-wrap { max-height: 50vh; }
  #stats-totals .stat-item { flex: 1 1 calc(50% - 8px); min-width: 100px; padding: 8px 12px; }
  #stats-totals .stat-item:last-child { flex: 1 1 100%; }
  #stats-totals .stat-value { font-size: 16px; }

  /* Table */
  .stats-table { font-size: 12px; }
  .stats-table th, .stats-table td { padding: 8px 10px; }
  .stats-table .actions-cell { gap: 3px; flex-wrap: nowrap; }
  .stats-table .actions-cell button { padding: 4px 8px; font-size: 10px; }
  .stats-table .stats-action-btn,
  .stats-table .rename-btn,
  .stats-table .set-default-btn,
  .stats-table .encrypt-btn,
  .stats-table .decrypt-btn,
  .stats-table .delete-btn { padding: 4px 7px; font-size: 10px; }
  .stats-table .encrypted-badge,
  .stats-table .default-badge { font-size: 10px; padding: 2px 6px; }
  .stats-table .status-badge { font-size: 10px; padding: 2px 6px; }
  .stats-table th, .stats-table td { white-space: nowrap; }
  .stats-pagination { flex-wrap: wrap; gap: 4px; }

  /* Results / Search */
  .results-info { flex-wrap: wrap; gap: 6px; }
  .search-chart-container { height: 200px; }
  #results-table { font-size: 12px; overflow-x: auto; display: block; }

  /* Aggregations */
  .agg-form { flex-wrap: wrap; gap: 8px; }
  .agg-type-toggle, .agg-view-toggle { flex-wrap: wrap; gap: 4px; }
  .agg-chart-container { height: 250px; }

  /* Modals */
  .modal-content { width: 95%; margin: 20px auto; padding: 16px; }
  .modal-content.upload-modal-content.wide { width: 95%; }
}

@media (max-width: 480px) {
  .header { padding: 8px 12px; }
  .header-brand { font-size: 16px; }
  .toolbar { padding: 8px 12px; }
  .main-content { padding: 8px 12px; }
  #tab-stats { padding: 8px 12px; }
  #main-tabs .tab { padding: 7px 12px; font-size: 12px; }
  .stats-totals .stat-item { flex: 1 1 100%; }
  .stats-table th:nth-child(4),
  .stats-table td:nth-child(4),
  .stats-table th:nth-child(5),
  .stats-table td:nth-child(5) { display: none; }
}
/* Indices Stats page */
/* ── Stats page ─────────────────────────────────────── */
/* .indices-stats-page styles already defined above */

/* ─── Stats Page ─────────────────────────────────────────────────────────────── */

/* #stats-totals styles already defined above */
#stats-totals .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 20px;
    border-right: 1px solid rgba(255,255,255,0.1);
    flex: 1;
}
#stats-totals .stat-item:last-child { border-right: none; }
#stats-totals .stat-label {
    font-size: 9px;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 600;
}
#stats-totals .stat-value {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
#stats-refresh-btn {
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 14px;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
#stats-refresh-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
}

/* Stats card grid — smaller, tighter index cards */
#stats-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 95%;
    margin: 0 auto;
}
#stats-cards .index-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.15s;
}
#stats-cards .index-card:hover { border-color: var(--primary); }
#stats-cards .index-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
    margin-bottom: 8px;
}
#stats-cards .index-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}
#stats-cards .index-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex: 1;
    overflow: hidden;
}
#stats-cards .index-card-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    align-items: center;
}
#stats-cards .index-card-actions button {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
#stats-cards .index-card-actions .encrypt-btn {
    background: rgba(17, 94, 89, 0.15);
    color: #115E59;
    border: 1px solid rgba(17, 94, 89, 0.3);
    font-weight: 600;
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
#stats-cards .index-card-actions .encrypt-btn:hover {
    background: #115E59;
    color: #ffffff;
}
#stats-cards .index-card-actions .decrypt-btn {
    background: rgba(17, 94, 89, 0.15);
    color: #115E59;
    border: 1px solid rgba(17, 94, 89, 0.3);
    font-weight: 600;
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
#stats-cards .index-card-actions .decrypt-btn:hover {
    background: #115E59;
    color: #ffffff;
}
#stats-cards .index-card-actions .delete-btn {
    background: #DC2626;
    color: #ffffff;
    border: 1px solid #DC2626;
    font-weight: 600;
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
#stats-cards .index-card-actions .delete-btn:hover {
    background: #B91C1C;
    border-color: #B91C1C;
}
#stats-cards .index-card-actions .small-btn {
    background: rgba(17, 94, 89, 0.15);
    color: #ffffff;
    border: 1px solid rgba(17, 94, 89, 0.3);
    font-weight: 600;
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
#stats-cards .index-card-actions .small-btn:hover {
    background: #115E59;
}
#stats-cards .encrypted-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    background: rgba(17, 94, 89, 0.12); color: #115E59;
    border-radius: 5px; font-size: 11px; font-weight: 700;
    border: 1px solid rgba(17, 94, 89, 0.2);
    white-space: nowrap;
}
#stats-cards .default-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    background: rgba(59, 130, 246, 0.12); color: #1e3a8a;
    border-radius: 5px; font-size: 11px; font-weight: 700;
    border: 1px solid rgba(59, 130, 246, 0.2);
    white-space: nowrap;
}
#stats-cards .job-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 600;
}
#stats-cards .job-badge.running { background: rgba(17, 94, 89, 0.1); color: #115E59; }
#stats-cards .job-badge.upload  { background: rgba(59, 130, 246, 0.1); color: #1D4ED8; }
#stats-cards .job-badge.interrupted { background: rgba(220, 38, 38, 0.1); color: #DC2626; }
#stats-cards .set-default-btn {
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 6px;
    background: rgba(17, 94, 89, 0.15);
    border: 1px solid rgba(17, 94, 89, 0.3);
    color: #115E59;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
}
#stats-cards .set-default-btn:hover { background: rgba(255,255,255,0.22); }
#stats-cards .index-stats-grid {
    display: flex;
    gap: 8px;
}
#stats-cards .index-stat {
    background: var(--surface-2);
    padding: 6px 12px;
    border-radius: 5px;
    text-align: center;
    flex: 1;
}
#stats-cards .index-stat .label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
#stats-cards .index-stat .value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}
#stats-cards .index-stat .value.bytes { font-size: 11px; }

#stats-cards .set-default-btn {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
}
#stats-cards .set-default-btn:hover { background: rgba(255,255,255,0.18); }

/* Badges in stats cards */
#stats-cards .encrypted-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    background: rgba(17, 94, 89, 0.12); color: #115E59;
    border-radius: 4px; font-size: 11px; font-weight: 700;
    border: 1px solid rgba(17, 94, 89, 0.2);
    white-space: nowrap;
}
#stats-cards .default-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    background: rgba(59, 130, 246, 0.12); color: #1e3a8a;
    border-radius: 4px; font-size: 11px; font-weight: 700;
    border: 1px solid rgba(59, 130, 246, 0.2);
    white-space: nowrap;
}
#stats-cards .job-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
}
#stats-cards .job-badge.running { background: rgba(17, 94, 89, 0.15); color: #115E59; }
#stats-cards .job-badge.upload  { background: rgba(59, 130, 246, 0.15); color: #1e3a8a; }
#stats-cards .job-badge.interrupted { background: rgba(220, 38, 38, 0.12); color: #991B1B; }

/* Progress info in card — matches upload popup style */
#stats-cards .index-card-progress {
    margin: 10px 0 0;
    padding: 10px 12px;
    background: rgba(17, 94, 89, 0.05);
    border-radius: 6px;
    border: 1px solid #99F6E4;
}
#stats-cards .index-card-progress .progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #134E4A;
    margin-bottom: 6px;
}
#stats-cards .index-card-progress .progress-row:last-child { margin-bottom: 0; }
#stats-cards .index-card-progress .progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}
#stats-cards .index-card-progress .progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease-out;
    background: linear-gradient(90deg, var(--primary), var(--success));
}
#stats-cards .index-card-progress .progress-fill.blue { background: linear-gradient(90deg, #3B82F6, #60A5FA); }
#stats-cards .index-card-progress .progress-fill.amber { background: linear-gradient(90deg, #115E59, #0F766E); }
#stats-cards .index-card-progress .progress-fill.red   { background: linear-gradient(90deg, #EF4444, #F87171); }

/* Encrypted msg in card */
#stats-cards .index-card-encrypted-msg {
    margin: 8px 0 0;
    padding: 8px 12px;
    background: rgba(17, 94, 89, 0.05);
    border-radius: 6px;
    border: 1px solid #99F6E4;
    font-size: 12px;
    color: #134E4A;
}

/* Empty state */
.stats-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.stats-empty p { font-size: 14px; }

/* Pagination */
.stats-pagination-wrap { width: 95%; margin: 0 auto; }
.stats-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; margin-top: 24px; padding-bottom: 20px;
}
.stats-pagination .page-btn {
    min-width: 34px; height: 34px; padding: 0 10px;
    border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all 0.15s;
}
.stats-pagination .page-btn:hover { border-color: var(--primary); color: var(--primary); }
.stats-pagination .page-btn.active {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.stats-pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stats-pagination .page-ellipsis { color: var(--text-muted); font-size: 14px; padding: 0 4px; }
.stats-page-info { font-size: 12px; color: var(--text-muted); margin-right: 6px; }

/* Action overlay for delete/encrypt/upload in progress */
.index-card-action-overlay {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(2px);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px; z-index: 10;
}
.index-card-action-overlay .progress-text {
    font-size: 13px; color: var(--text); font-weight: 500;
}
.index-card-action-overlay .progress-bar {
    width: 70%; height: 5px;
    background: #99F6E4; border-radius: 3px; overflow: hidden;
}
.index-card-action-overlay .progress-fill {
    height: 100%; background: var(--primary);
    border-radius: 3px; transition: width 0.3s;
}
.index-card-action-overlay .progress-text.error {
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    background: rgba(254, 226, 226, 0.95);
    border: 1px solid #FECACA;
    border-radius: 6px;
    padding: 8px 14px;
    width: 90%;
    text-align: center;
}



/* Empty state */
.stats-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.stats-empty-icon { font-size: 48px; margin-bottom: 12px; }
.stats-empty p { font-size: 14px; }

/* Pagination */
.stats-pagination-wrap { width: 95%; margin: 0 auto; }
.stats-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
    padding-bottom: 20px;
}
.stats-pagination .page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stats-pagination .page-btn:hover:not(:disabled) {
    border-color: #115E59;
    color: #115E59;
    background: rgba(17, 94, 89, 0.08);
}
.stats-pagination .page-btn.active {
    background: linear-gradient(135deg, #115E59, #115E59);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.stats-pagination .page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.stats-pagination .page-ellipsis {
    color: var(--text-muted);
    font-size: 14px;
    padding: 0 4px;
}
.stats-page-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 8px;
    font-weight: 500;
}

/* Mapping dialog */
.mapping-modal-content {
    max-width: 700px;
    width: 90%;
}
.mapping-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.mapping-modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.mapping-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mapping-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.mapping-close:hover { color: var(--text); }
#mapping-modal-body pre {
    background: rgba(17, 94, 89, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    max-height: 60vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    color: var(--text);
    line-height: 1.6;
}

/* Encrypted state in card */
.stats-card-encrypted-msg {
    margin: 0 18px 14px;
    padding: 12px 14px;
    background: rgba(17, 94, 89, 0.05);
    border: 1px solid #99F6E4;
    border-radius: 8px;
    font-size: 12px;
    color: #134E4A;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sticky upload banner on search page */
.upload-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 1px solid #F59E0B;
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #92400E;
    cursor: pointer;
}
.upload-banner:hover { background: linear-gradient(135deg, #FDE68A, #FCD34D); }
.upload-banner.hidden { display: none; }
.upload-banner #upload-banner-detail { font-weight: 400; color: #B45309; }
.upload-banner .logs-btn {
    padding: 4px 10px;
    background: rgba(180, 83, 9, 0.15);
    border: 1px solid rgba(180, 83, 9, 0.4);
    border-radius: var(--radius);
    color: #92400E;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}
.upload-banner .logs-btn:hover { background: rgba(180, 83, 9, 0.25); }



/* ═══════════════════════════════════════════════════════════════════
   ── POLISH LAYER ────────────────────────────────────────────────────
   Refines high-visibility elements for premium screenshots.
   Bumps hardcoded radii, softens shadows, adds breathing room.
═══════════════════════════════════════════════════════════════════ */

/* ── Header refinements ── */
.header { padding: 0 28px; height: 64px; box-shadow: 0 1px 0 rgba(0,0,0,0.06); }
.header .upload-btn { border-radius: 10px; padding: 9px 18px; font-weight: 600; transition: all 0.18s ease; }
.header .upload-btn:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
.cluster-status-btn { border-radius: 10px; padding: 9px 18px; transition: all 0.18s ease; }
.cluster-status-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25); }

/* ── Toolbar refinements ── */
.toolbar { padding: 12px 24px; gap: 14px; }
.toolbar .search-box input,
.toolbar .toolbar-actions input { border-radius: 10px; padding: 9px 14px; transition: border-color 0.15s ease; }
.toolbar .search-box input:focus,
.toolbar .toolbar-actions input:focus { border-color: #99F6E4; box-shadow: 0 0 0 3px rgba(153, 246, 228, 0.18); outline: none; }
.toolbar .search-box button { border-radius: 10px; padding: 9px 20px; font-weight: 600; transition: all 0.15s ease; }
.toolbar .search-box button:hover { background: #115E59; transform: translateY(-1px); }
.toolbar .secondary-btn,
.secondary-btn { border-radius: 10px; padding: 9px 16px; transition: all 0.15s ease; }
.custom-dropdown .dropdown-toggle { border-radius: 10px; padding: 9px 16px; transition: all 0.15s ease; }
.custom-dropdown .dropdown-menu { border-radius: 12px; box-shadow: 0 16px 40px rgba(13, 77, 68, 0.18), 0 4px 12px rgba(13, 77, 68, 0.08); border-color: #99F6E4; padding: 6px; }
.custom-dropdown .dropdown-item { border-radius: 8px; padding: 9px 12px; transition: all 0.12s ease; }
.custom-dropdown .dropdown-item.selected { background: rgba(17, 94, 89, 0.10); }

/* ── Main tabs ── */
#main-tabs { border-radius: 12px 12px 0 0; padding: 6px; gap: 4px; }
#main-tabs .tab { border-radius: 8px; padding: 10px 20px; transition: all 0.15s ease; }
#main-tabs .tab.active { box-shadow: 0 2px 8px rgba(17, 94, 89, 0.22); }

/* ── Content panel ── */
.content { border-radius: 12px; box-shadow: 0 2px 8px rgba(13, 77, 68, 0.04); overflow: hidden; }
.tab-content { padding: 22px; }

/* ── Modal — premium ── */
.modal { background: rgba(13, 78, 74, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-content {
    border-radius: 18px;
    padding: 28px 32px;
    box-shadow: 0 32px 80px rgba(13, 77, 68, 0.28), 0 12px 32px rgba(13, 77, 68, 0.12);
    border: 1px solid rgba(153, 246, 228, 0.4);
    margin: 60px auto;
}
.modal h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 22px; }
.modal .close { border-radius: 8px; width: 34px; height: 34px; right: 20px; top: 18px; transition: all 0.15s ease; }
.modal .close:hover { background: rgba(17, 94, 89, 0.08); color: #115E59; }
.modal-content pre { border-radius: 10px; padding: 16px 18px; }

/* ── Upload dropzone — premium ── */
.upload-dropzone {
    border-radius: 14px;
    padding: 56px 36px;
    border-width: 2px;
    border-color: #99F6E4;
    background: linear-gradient(180deg, rgba(204, 251, 241, 0.4), rgba(240, 253, 250, 0.6));
    transition: all 0.2s ease;
}
.upload-dropzone:hover {
    border-color: #115E59;
    background: linear-gradient(180deg, rgba(204, 251, 241, 0.6), rgba(204, 251, 241, 0.4));
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(17, 94, 89, 0.10);
}
.upload-dropzone.dragover {
    border-color: #059669;
    background: linear-gradient(180deg, rgba(204, 251, 241, 0.8), rgba(153, 246, 228, 0.5));
}
.upload-dropzone p { font-size: 15px; margin-bottom: 14px; }
.upload-dropzone .hint { font-size: 13px; }

#browse-btn,
.upload-summary .primary-btn,
.modal .primary-btn {
    border-radius: 10px;
    padding: 11px 24px;
    font-size: 14px;
    transition: all 0.18s ease;
}
.modal .primary-btn:hover:not(:disabled),
#browse-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(17, 94, 89, 0.22); }

/* ── Upload progress ── */
.upload-progress { border-radius: 12px; padding: 20px; background: rgba(204, 251, 241, 0.4); border: 1px solid #99F6E4; }
.upload-progress .progress-bar { border-radius: 6px; height: 10px; }
.upload-progress .progress-fill { border-radius: 6px; }

/* ── Step indicators ── */
.step-num { border-radius: 8px; width: 30px; height: 30px; box-shadow: 0 2px 6px rgba(17, 94, 89, 0.22); }
.step-header { padding-bottom: 16px; }

/* ── File meta grid ── */
.file-meta { border-radius: 12px; padding: 18px; background: rgba(204, 251, 241, 0.4); border: 1px solid #99F6E4; }

/* ── Mapping & sample tables ── */
.table-scroll { border-radius: 12px; border-color: #99F6E4; }
.mapping-table th { padding: 12px 14px; background: rgba(204, 251, 241, 0.5); }
.mapping-table td { padding: 12px 14px; }
.mapping-table .type-badge { border-radius: 6px; padding: 4px 11px; font-size: 11.5px; }

/* ── Form inputs ── */
.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    border-radius: 10px;
    padding: 11px 14px;
    border-color: #99F6E4;
    transition: all 0.15s ease;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #115E59;
    box-shadow: 0 0 0 3px rgba(17, 94, 89, 0.10);
}
.form-group label { font-size: 13px; margin-bottom: 7px; font-weight: 600; color: #134E4A; }

/* ── Buttons ── */
.primary-btn {
    border-radius: 10px;
    padding: 11px 22px;
    transition: all 0.18s ease;
    box-shadow: 0 2px 6px rgba(17, 94, 89, 0.18);
}
.primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(17, 94, 89, 0.28);
}
.small-btn { border-radius: 8px; padding: 7px 14px; }

/* ── Results table refinements ── */
#results-table { border-radius: 12px; box-shadow: 0 2px 8px rgba(13, 77, 68, 0.04); }
#results-table th { padding: 12px 14px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #115E59; }
#results-table td { padding: 12px 14px; }
#results-table .doc-detail pre { border-radius: 10px; padding: 14px; }
.data-cell { padding-right: 24px; }
.cell-filter { border-radius: 6px; width: 22px; height: 22px; right: 4px; }

/* ── Stats table refinements ── */
.stats-table-wrap { border-radius: 12px; border-color: #99F6E4; box-shadow: 0 2px 8px rgba(13, 77, 68, 0.04); }
.stats-table th { padding: 12px 16px; }
.stats-table td { padding: 12px 16px; }
.stats-table .actions-cell button { border-radius: 8px; padding: 6px 14px; }
.stats-table .status-badge,
.stats-table .encrypted-badge,
.stats-table .default-badge { border-radius: 6px; padding: 4px 10px; }
#stats-cards .index-card { border-radius: 12px; padding: 14px 16px; transition: all 0.18s ease; }
#stats-cards .index-card:hover { box-shadow: 0 4px 16px rgba(17, 94, 89, 0.10); transform: translateY(-1px); }
#stats-cards .index-card-actions button { border-radius: 8px; padding: 7px 14px; }

/* ── Stats totals card ── */
#stats-totals { border-radius: 14px; box-shadow: 0 4px 18px rgba(13, 148, 136, 0.20); }

/* ── Search chart container ── */
.search-chart-container.visible { border-radius: 12px; padding: 16px 18px; border: 1px solid #99F6E4; }

/* ── Filter tags & popups ── */
.filter-tag { border-radius: 8px; padding: 5px 11px; font-size: 12.5px; }
.filter-popup { border-radius: 14px; box-shadow: 0 24px 56px rgba(13, 77, 68, 0.22); border-color: #99F6E4; }
.filter-popup-header { padding: 16px 20px; }
.filter-item { border-radius: 10px; padding: 14px; }
.filter-item select,
.filter-item input { border-radius: 8px; padding: 8px 12px; }
.filter-item .remove-filter { border-radius: 8px; }

/* ── Map toolbar ── */
#map-toolbar { border-radius: 12px; padding: 14px; }
.map-field-selects select { border-radius: 8px; padding: 9px 14px; }
.map-size-input input { border-radius: 8px; padding: 7px 10px; }
#map-container { border-radius: 14px; box-shadow: 0 4px 18px rgba(13, 77, 68, 0.10); border-color: #99F6E4; }

/* ── Aggregation form row ── */
.agg-form-row { border-radius: 12px; padding: 14px 16px; }
.agg-form select { border-radius: 8px; padding: 8px 12px; }
.agg-form input { border-radius: 8px; padding: 8px 10px; }
.agg-type-toggle .type-btn,
.view-btn { border-radius: 8px; padding: 6px 12px; }
.agg-pagination button { border-radius: 8px; padding: 8px 16px; }

/* ── Pagination ── */
.pagination button { border-radius: 8px; padding: 8px 14px; transition: all 0.15s ease; }

/* ── Format info / badges ── */
.format-info { border-radius: 10px; padding: 14px 18px; }
.format-info .badge { border-radius: 6px; padding: 4px 11px; }

/* ── Sheet button ── */
.sheet-btn { border-radius: 8px; padding: 6px 16px; }

/* ── Success / error msg ── */
.success-msg { border-radius: 12px; padding: 16px 22px; border-color: #99F6E4; }
.error-msg { border-radius: 10px; padding: 14px 16px; }
.error-summary { border-radius: 10px; padding: 16px; }
.error-detail-item { border-radius: 8px; padding: 14px; }

/* ── Doc modal JSON viewer ── */
#doc-modal-body pre { border-radius: 12px; padding: 20px; }

/* ── Scrollbar refinement ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #99F6E4; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #14B8A6; }

/* ── Index cards (legacy /indices page) ── */
.index-card { border-radius: 14px; padding: 20px; transition: all 0.2s ease; }
.index-card:hover { box-shadow: 0 8px 24px rgba(17, 94, 89, 0.10); transform: translateY(-2px); }
.index-card-actions button { border-radius: 8px; padding: 7px 14px; }
.index-stat { border-radius: 10px; padding: 14px; }
.indices-totals { border-radius: 14px; box-shadow: 0 6px 24px rgba(17, 94, 89, 0.18); }

/* ── Encrypted badge ── */
.encrypted-badge { border-radius: 6px; padding: 4px 10px; }

/* ── Body background — soft tint instead of pure white for screenshot warmth ── */
body { background: #FAFEFD; }

