/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    background: #f5f7fa;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #2c3e50;
    color: #ecf0f1;
    padding: 20px 0 60px 0; /* Bottom padding to prevent content from hiding behind version */
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 9999; /* Ensure sidebar is always on top - navigation should never be covered */
    transition: transform 0.3s ease; /* Smooth slide animation */
}

.sidebar .logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid #34495e;
    margin-bottom: 20px;
}

.sidebar h2 {
    font-size: 20px;
    font-weight: 600;
}

.nav-section {
    margin-bottom: 25px;
}

.nav-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #95a5a6;
    padding: 0 20px 10px;
    font-weight: 600;
}

.nav-section ul {
    list-style: none;
}

.nav-section li a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-section li a:hover {
    background: #34495e;
    border-left: 3px solid #3498db;
    padding-left: 17px;
}

.nav-section li a.active {
    background: #34495e;
    border-left: 3px solid #3498db;
    padding-left: 17px;
    font-weight: 600;
}

.nav-section li a .icon {
    margin-right: 10px;
    font-size: 16px;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 222px; /* Position at right edge of sidebar (260px - 38px for button and padding) */
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ecf0f1;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease; /* Match sidebar transition */
    z-index: 10001; /* Above sidebar content */
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

.sidebar-toggle .toggle-icon {
    line-height: 1;
    font-weight: bold;
}

/* Collapsed sidebar state */
.sidebar-collapsed .sidebar {
    transform: translateX(-260px);
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

.sidebar-collapsed .sidebar-toggle {
    left: 10px; /* Move to left edge when collapsed */
    background: #2c3e50;
    border-color: #34495e;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 20px;
    transition: margin-left 0.3s ease; /* Smooth expand animation */
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
}

.content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-card:nth-child(5) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-card:nth-child(6) {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
}

.stat-icon {
    font-size: 36px;
    margin-right: 15px;
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
    word-break: break-word;
    line-height: 1.2;
}

.stat-content p {
    font-size: 13px;
    opacity: 0.9;
}

/* Quality Grid */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.quality-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.quality-card.quality-good {
    border-color: #4caf50;
    background: #f1f8e9;
}

.quality-card.quality-warning {
    border-color: #ff9800;
    background: #fff3e0;
}

.quality-card.quality-error {
    border-color: #f44336;
    background: #ffebee;
}

.quality-card h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #666;
}

.quality-value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.quality-label {
    font-size: 12px;
    color: #999;
}

/* Health Score Card */
.health-score-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-left: 6px solid #4caf50;
}

.health-score-card.health-excellent {
    border-left-color: #4caf50;
}

.health-score-card.health-good {
    border-left-color: #2196f3;
}

.health-score-card.health-fair {
    border-left-color: #ff9800;
}

.health-score-card.health-poor {
    border-left-color: #f44336;
}

.health-score-content {
    display: flex;
    align-items: center;
    gap: 30px;
}

.health-score-icon {
    font-size: 64px;
}

.health-score-details {
    flex: 1;
}

.health-score-details h2 {
    font-size: 18px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

.health-score-value {
    font-size: 48px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
    margin-bottom: 5px;
}

.health-score-status {
    font-size: 20px;
    font-weight: 600;
    color: #666;
}

.health-score-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.breakdown-label {
    font-size: 14px;
    color: #666;
}

.breakdown-value {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
}

/* Completeness Grid */
.completeness-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.completeness-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.completeness-card h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.completeness-progress {
    margin-bottom: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    border-radius: 12px;
    transition: width 0.3s ease;
    background: #4caf50;
}

.progress-percentage {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    margin-top: 8px;
}

.completeness-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 14px;
    color: #666;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 30px 0 15px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

/* Revenue Analytics */
.revenue-analytics {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.analytics-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.analytics-card-wide {
    grid-column: span 3;
}

.analytics-card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.analytics-card canvas {
    max-height: 300px;
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* Customer Analytics */
.customer-analytics {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.retention-metrics {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.retention-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.retention-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.retention-icon {
    font-size: 24px;
}

.retention-details {
    flex: 1;
}

.retention-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
}

.retention-value {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

/* Top Lists Grid */
.top-lists-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.top-list-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.top-list-card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.top-list {
    max-height: 400px;
    overflow-y: auto;
}

.top-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.top-list-table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
}

.top-list-table th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #e0e0e0;
}

.top-list-table td {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.top-list-table tbody tr:hover {
    background: #f8f9fa;
}

.top-list-table th:first-child,
.top-list-table td:first-child {
    width: 40px;
    text-align: center;
    color: #999;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-bottom: 30px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead {
    background: #f8f9fa;
}

.data-table th {
    padding: 4px 6px;
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

/* Header row cells - stick at top */
.data-table thead tr:first-child th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 12;
}

/* Filter row cells - stick below header row */
.data-table thead tr:nth-child(2) th {
    position: sticky;
    top: 28px;
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    padding: 2px 6px;
    z-index: 11;
}

.data-table th:hover {
    background: #e9ecef;
}

/* Header row hover */
.data-table thead tr:first-child th:hover {
    background: #e9ecef;
}

/* Filter row hover shouldn't change background */
.data-table thead tr:nth-child(2) th:hover {
    background: #ffffff;
}

.data-table th.sortable::after {
    content: ' ⇅';
    opacity: 0.3;
    font-size: 10px;
}

.data-table th.sorted-asc::after {
    content: ' ▲';
    opacity: 1;
}

.data-table th.sorted-desc::after {
    content: ' ▼';
    opacity: 1;
}

.data-table th.resizable {
    position: relative;
}

.data-table th .resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    z-index: 11;
}

.data-table th .resize-handle:hover {
    background: #3498db;
}

.data-table td {
    padding: 3px 6px;
    border-bottom: 1px solid #dee2e6;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table tbody tr.clickable-row {
    cursor: pointer;
}

.data-table tbody tr.clickable-row:hover {
    background: #e3f2fd;
}

.data-table td.null-value {
    color: #999;
    font-style: italic;
}

.data-table td.loading,
.data-table td.error {
    text-align: center;
    padding: 40px;
    color: #999;
}

.data-table td.error {
    color: #f44336;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: white;
}

.btn-primary {
    background: #3498db;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Browse Page */
.browse-container {
    max-width: 100%;
}

.browse-controls {
    display: flex;
    justify-content: flex-start; /* Left-align all controls */
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 4px;
    gap: 15px;
    flex-wrap: wrap;
}

.column-controls {
    position: relative;
}

.column-toggle-btn {
    padding: 6px 12px;
    font-size: 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.column-toggle-btn:hover {
    background: #5a6268;
}

.column-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    min-width: 200px;
    margin-top: 5px;
}

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

.column-dropdown label {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.column-dropdown label:hover {
    background: #f8f9fa;
}

.column-dropdown input[type="checkbox"] {
    margin-right: 8px;
}

/* Drop indicator for column reordering */
.column-dropdown label.drop-indicator-top::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #007bff;
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.6);
    z-index: 10;
}

.column-dropdown label.drop-indicator-bottom::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #007bff;
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.6);
    z-index: 10;
}

.column-dropdown label {
    position: relative;
}

.bulk-actions-bar {
    display: none;
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    align-items: center;
    gap: 15px;
}

.bulk-actions-bar.show {
    display: flex;
}

.bulk-actions-bar .selected-count {
    font-weight: 600;
    color: #856404;
}

.bulk-actions-bar .bulk-buttons {
    display: flex;
    gap: 10px;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.select-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.select-all-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.record-count {
    font-weight: 600;
    color: #666;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
}

.column-filter {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.scroll-loader {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 10px;
}

.loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

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

/* Global Loading Spinner */
.global-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.global-spinner .spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 0.8s linear infinite;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 260px; /* Start after sidebar */
    top: 0;
    width: calc(100% - 260px); /* Width of main content area only */
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

/* When sidebar is collapsed, use full width (modals are siblings of .layout) */
.sidebar-collapsed ~ .modal {
    left: 0;
    width: 100%;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

/* Changelog modal - no scrollbar on modal-content, only on modal-body */
#changelogModal .modal-content {
    overflow-y: visible;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    font-size: 28px;
    font-weight: 300;
    color: #999;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-body h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-top: 15px;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e9ecef;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 500px;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-input-large {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    margin-bottom: 15px;
}

.search-select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
}

.result-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    border-left: 4px solid #3498db;
}

.result-card h4 {
    margin-bottom: 10px;
}

.result-card p {
    margin: 5px 0;
    color: #666;
}

/* Customer Detail */
.customer-detail {
    max-width: 1200px;
}

.detail-card {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.detail-card h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #2c3e50;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item label {
    font-weight: 600;
    color: #666;
    font-size: 12px;
    margin-bottom: 5px;
}

.detail-item span {
    font-size: 14px;
    color: #333;
}

.warning-card {
    background: #fff3e0;
    border: 2px solid #ff9800;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
}

.warning-card h3 {
    color: #e65100;
    margin-bottom: 10px;
}

/* Duplicates */
.duplicate-group {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.duplicate-customers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.duplicate-card {
    background: white;
    padding: 15px;
    border-radius: 4px;
    border: 2px solid #ddd;
}

.duplicate-card h4 {
    margin-bottom: 10px;
}

.duplicate-card p {
    margin: 5px 0;
    color: #666;
    font-size: 13px;
}

/* Quality Section */
.quality-section {
    margin-bottom: 40px;
}

.quality-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ==================== Mobile Responsive Design ==================== */

/* Hamburger Menu Button (Mobile Only) */
.hamburger-menu {
    display: none; /* Hidden on desktop */
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1100;
    background: #2c3e50;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    width: 48px;
    height: 48px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.hamburger-menu:hover {
    background: #34495e;
    transform: scale(1.05);
}

.hamburger-menu:active {
    transform: scale(0.95);
}

/* Hamburger Lines */
.hamburger-line {
    display: block;
    width: 24px;
    height: 3px;
    background: #ecf0f1;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Hamburger Animation when Active */
.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Mobile Overlay (darkens background when menu is open) */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Show hamburger menu on mobile */
    .hamburger-menu {
        display: flex;
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        left: -280px; /* Hidden off-screen */
        width: 280px;
        height: 100vh;
        z-index: 9999; /* Ensure sidebar is always on top - navigation should never be covered */
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    /* Show sidebar when mobile menu is open */
    .sidebar.mobile-open {
        left: 0;
    }

    /* Expand main content to full width on mobile */
    .main-content {
        margin-left: 0;
        padding: 70px 12px 15px 12px; /* Extra top padding for hamburger button, reduced side padding */
        width: 100%;
        overflow-x: hidden; /* Prevent horizontal overflow */
    }

    /* Modal takes full width on mobile */
    .modal {
        left: 0;
        width: 100%;
    }

    /* Show overlay when menu is open */
    .mobile-overlay.active {
        display: block;
    }

    /* Force content to fit viewport */
    .content {
        padding: 15px 12px; /* Reduced from 30px */
        margin: 0; /* Ensure no margins */
        overflow-x: hidden; /* Prevent overflow */
    }

    /* Stats grid - single column on mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px; /* Reduced gap */
        margin-bottom: 20px; /* Reduced margin */
    }

    /* Stat cards - improve text wrapping on mobile */
    .stat-card {
        flex-wrap: wrap;
        padding: 14px; /* Reduced padding */
        gap: 10px;
    }

    .stat-icon {
        font-size: 26px; /* Slightly smaller */
        margin-right: 0;
        flex-shrink: 0;
        flex-basis: 100%; /* Force icon to its own line */
        text-align: center;
    }

    .stat-content {
        flex: 1 100%; /* Full width on mobile */
        min-width: 0;
        text-align: left; /* Align left, not center - prevents overflow */
    }

    .stat-content h3 {
        font-size: 18px; /* Reduced from 20px */
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.1;
    }

    .stat-content p {
        font-size: 12px;
        word-break: break-word;
    }

    /* Page header - stack vertically */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding-top: 10px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    /* Quality grid - single column */
    .quality-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Health Score Card - stack vertically on mobile */
    .health-score-content {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .health-score-icon {
        font-size: 48px;
        text-align: center;
    }

    .health-score-details {
        flex: 1;
    }

    .health-score-breakdown {
        width: 100%;
        min-width: auto;
    }

    /* Revenue analytics - stack vertically */
    .revenue-analytics {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .analytics-card-wide {
        grid-column: span 1;
    }

    .analytics-card canvas {
        max-height: 250px;
        width: 100% !important;
        height: auto !important;
    }

    /* Customer analytics - stack vertically */
    .customer-analytics {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Top lists grid - stack vertically */
    .top-lists-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .top-list-card[style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }

    /* Retention stats - single column on small mobile */
    .retention-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Table display - horizontal scroll with better control */
    .top-list-table {
        font-size: 12px;
    }

    .top-list-table th,
    .top-list-table td {
        padding: 8px 6px;
        font-size: 11px;
    }

    .top-list-table th:first-child,
    .top-list-table td:first-child {
        width: 30px;
    }

    .top-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 300px;
    }

    /* Browse controls - stack vertically */
    .browse-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    /* Search container - full width */
    .search-container {
        max-width: 100%;
    }

    /* Table wrapper - reduce max height on mobile */
    .table-wrapper {
        max-height: calc(100vh - 250px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modal adjustments for mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px;
        max-height: 90vh;
    }

    /* Completeness grid - single column */
    .completeness-grid {
        grid-template-columns: 1fr;
    }

    .completeness-card h3 {
        font-size: 16px;
    }

    /* Detail grid - single column */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    /* Duplicate customers - single column */
    .duplicate-customers {
        grid-template-columns: 1fr;
    }

    /* Pair customers - responsive layout */
    .pair-customers {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }

    .pair-divider {
        display: none;
    }

    /* Content padding adjustment */
    .content {
        padding: 20px 15px;
    }

    /* Button adjustments for mobile */
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        text-align: center;
    }

    .btn-sm {
        padding: 8px 12px;
        font-size: 12px;
        width: auto;
    }

    /* Section header - stack for mobile */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .section-header a {
        width: 100%;
    }

    /* SIDS button container */
    .sids-button-container {
        flex-direction: column;
    }

    .sids-lookup-button {
        width: 100%;
        justify-content: center;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .hamburger-menu {
        top: 10px;
        left: 10px;
        width: 44px;
        height: 44px;
    }

    .main-content {
        padding: 65px 8px 10px 8px; /* Minimal padding */
        overflow-x: hidden; /* Absolute prevention */
    }

    /* Minimal content padding on tiny screens */
    .content {
        padding: 12px 8px;
        margin: 0;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* Dashboard container */
    .dashboard {
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .page-header {
        gap: 10px;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .page-header h1 {
        font-size: 18px;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .stat-card {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
        overflow: hidden; /* Prevent overflow from text */
    }

    .stat-icon {
        font-size: 22px;
        margin-right: 0;
        flex-basis: 100%;
        text-align: center;
    }

    .stat-content {
        flex: 1 100%;
        text-align: left; /* Left align prevents overflow issues */
    }

    .stat-content h3 {
        font-size: 16px;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.1; /* Tighter line height saves space */
    }

    .stat-content p {
        font-size: 11px;
        word-break: break-word;
    }

    /* Health score card on very small screens */
    .health-score-card {
        padding: 20px 15px;
    }

    .health-score-icon {
        font-size: 40px;
    }

    .health-score-value {
        font-size: 36px;
    }

    .health-score-status {
        font-size: 16px;
    }

    .breakdown-item {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Completeness card improvements */
    .completeness-card {
        padding: 15px;
    }

    .completeness-card h3 {
        font-size: 14px;
    }

    .progress-percentage {
        font-size: 14px;
    }

    .detail-row {
        font-size: 12px;
        flex-direction: column;
        gap: 4px;
    }

    /* Analytics cards smaller on tiny screens */
    .analytics-card h3 {
        font-size: 14px;
    }

    .analytics-card canvas {
        max-height: 200px;
        width: 100% !important;
        height: auto !important;
    }

    /* Retention stats on small screens */
    .retention-stat {
        padding: 8px;
        gap: 8px;
    }

    .retention-icon {
        font-size: 20px;
        flex-shrink: 0;
    }

    .retention-label {
        font-size: 11px;
    }

    .retention-value {
        font-size: 16px;
    }

    /* Top list table on tiny screens */
    .top-list-table {
        font-size: 10px;
    }

    .top-list-table th,
    .top-list-table td {
        padding: 4px 4px;
        font-size: 10px;
    }

    .top-list-table th:first-child,
    .top-list-table td:first-child {
        width: 25px;
    }

    .top-list {
        max-height: 250px;
    }

    /* Smaller modals on very small screens */
    .modal-content {
        width: 98%;
        margin: 5px;
        max-height: 85vh;
    }

    /* Data table adjustments */
    .data-table {
        font-size: 11px;
    }

    .data-table th,
    .data-table td {
        padding: 4px;
    }

    /* Customer card on tiny screens */
    .customer-card {
        padding: 12px;
    }

    .customer-card h4 {
        font-size: 14px;
    }

    .customer-details {
        font-size: 11px;
    }

    /* Merge actions - stack vertically on tiny screens */
    .merge-actions {
        flex-direction: column;
    }

    .merge-actions button {
        width: 100%;
        padding: 8px 12px;
        font-size: 11px;
        min-width: auto;
    }

    /* Duplicate controls */
    .pair-header {
        padding: 12px 15px;
    }

    .pair-number {
        font-size: 12px;
    }

    .similarity-badge {
        padding: 4px 10px;
        font-size: 11px;
    }

    /* Very compact button styling for tiny screens */
    .btn {
        padding: 10px 14px;
        font-size: 13px;
        width: 100%;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 11px;
        width: auto;
    }
}

/* Ultra-small screens (320px - iPhone SE, etc.) */
@media (max-width: 360px) {
    * {
        box-sizing: border-box;
    }

    .main-content {
        padding: 60px 6px 8px 6px !important;
        width: 100vw;
        margin: 0;
        overflow-x: hidden;
    }

    .content {
        padding: 10px 6px !important;
        margin: 0 !important;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .dashboard {
        width: 100%;
        overflow-x: hidden;
    }

    .stats-grid,
    .completeness-grid,
    .revenue-analytics,
    .customer-analytics,
    .top-lists-grid {
        width: 100%;
        overflow-x: hidden;
    }

    .stat-card {
        padding: 10px !important;
        gap: 6px;
        overflow: hidden;
    }

    .stat-icon {
        font-size: 20px;
    }

    .stat-content h3 {
        font-size: 14px;
    }

    .stat-content p {
        font-size: 10px;
    }

    /* Health score card on ultra-small screens */
    .health-score-card {
        padding: 15px 10px !important;
        margin: 0 !important;
    }

    .health-score-icon {
        font-size: 36px;
    }

    .health-score-value {
        font-size: 28px;
    }

    .health-score-status {
        font-size: 14px;
    }

    .breakdown-item {
        font-size: 11px;
        padding: 5px 8px;
    }

    /* Completeness cards */
    .completeness-card {
        padding: 12px !important;
    }

    .completeness-card h3 {
        font-size: 13px;
    }

    .progress-percentage {
        font-size: 12px;
    }

    .detail-label,
    .detail-value {
        font-size: 11px;
    }

    /* Analytics cards */
    .analytics-card {
        padding: 15px !important;
    }

    .analytics-card h3 {
        font-size: 12px;
    }

    .analytics-card canvas {
        max-height: 180px;
        width: 100% !important;
        height: auto !important;
    }

    /* Tables */
    .top-list-table {
        font-size: 9px;
    }

    .top-list-table th,
    .top-list-table td {
        padding: 3px 3px;
    }

    /* Section headers */
    .section-header {
        gap: 8px;
    }

    .section-header h2 {
        font-size: 16px;
    }

    /* Forms and inputs */
    .form-control,
    .search-input,
    input,
    select {
        font-size: 14px; /* Prevent zoom on iOS */
        max-width: 100%;
    }

    /* Modals */
    .modal-content {
        width: 98% !important;
        margin: 5px auto !important;
        max-height: 85vh;
    }

    .modal-header {
        padding: 15px 10px;
    }

    .modal-body {
        padding: 15px 10px;
    }

    /* Buttons */
    .btn {
        font-size: 12px;
        padding: 9px 12px;
        width: 100%;
    }

    /* SIDS button */
    .sids-lookup-button {
        font-size: 13px;
        padding: 12px 16px;
    }

    .sids-lookup-button .text {
        font-size: 12px;
    }
}

/* Responsive (Legacy - kept for backward compatibility) */
@media (max-width: 768px) {
    /* These rules are now handled above, but kept for any edge cases */
}

/* Source File Viewer Styles */
.source-line {
    display: flex;
    line-height: 1.6;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 13px;
    padding: 2px 0;
}

.source-line.highlight-line {
    background-color: #ffff99;
    font-weight: bold;
}

.line-num {
    min-width: 50px;
    padding-right: 12px;
    text-align: right;
    color: #999;
    border-right: 1px solid #ddd;
    margin-right: 12px;
    user-select: none;
}

.line-text {
    flex: 1;
    white-space: pre;
    overflow-x: auto;
}

/* ==================== Duplicate Detection Page ==================== */

.duplicates-page {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.duplicates-controls {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.duplicates-controls .control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duplicates-controls label {
    font-weight: 600;
    font-size: 13px;
    color: #555;
}

.duplicates-controls select,
.duplicates-controls .form-control {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    min-width: 220px;
}

.threshold-slider {
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

.threshold-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
}

.algorithm-info {
    padding: 15px 20px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #1565c0;
}

.results-summary {
    padding: 15px 20px;
    background: #f1f8e9;
    border-left: 4px solid #8bc34a;
    border-radius: 4px;
    margin-bottom: 20px;
    font-weight: 600;
    color: #558b2f;
}

.placeholder-text {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 15px;
}

.loading-spinner {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.duplicate-pair {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.pair-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.pair-number {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.similarity-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
}

.similarity-badge.high {
    background: #d4edda;
    color: #155724;
}

.similarity-badge.medium {
    background: #fff3cd;
    color: #856404;
}

.similarity-badge.low {
    background: #f8d7da;
    color: #721c24;
}

.pair-details {
    padding: 12px 20px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.match-details {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.pair-customers {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    padding: 20px;
}

.customer-card {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
}

.customer-label {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 10px;
}

.customer-card h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
}

.customer-card h4 a {
    color: #007bff;
    text-decoration: none;
}

.customer-card h4 a:hover {
    text-decoration: underline;
}

.customer-details {
    font-size: 12px;
}

.customer-details p {
    margin: 6px 0;
    color: #555;
}

.customer-details strong {
    color: #333;
    font-weight: 600;
    min-width: 70px;
    display: inline-block;
}

.pair-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.merge-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.merge-actions button {
    white-space: nowrap;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    min-width: 120px;
}

.merge-success {
    grid-column: 1 / -1;
    text-align: center;
    padding: 15px;
    background: #d4edda;
    color: #155724;
    border-radius: 6px;
    font-weight: 600;
    margin-top: 15px;
}

/* No results message */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Error message */
.error {
    text-align: center;
    padding: 40px 20px;
    color: #d32f2f;
    font-size: 14px;
    background: #ffebee;
    border-radius: 8px;
    border: 1px solid #ef9a9a;
}

/* Responsive design for duplicate pairs */
@media (max-width: 1200px) {
    .pair-customers {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .pair-divider {
        padding: 10px 0;
    }

    .merge-actions {
        flex-direction: row;
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .duplicates-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .duplicates-controls .control-group {
        width: 100%;
    }

    .duplicates-controls select,
    .duplicates-controls .form-control {
        width: 100%;
        min-width: unset;
    }

    .threshold-slider {
        width: 100%;
    }
}

/* ==================== Database Switcher Styles ==================== */

.current-database-indicator {
    padding: 0 20px;
}

#currentDatabaseDisplay {
    transition: all 0.2s ease;
}

#currentDatabaseDisplay:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
    color: rgba(255,255,255,1);
}

#currentDatabaseDisplay:active {
    transform: scale(0.98);
}

/* Database switcher modal specific styles */
#databaseSwitcherModal .modal-content {
    max-width: 500px;
    max-height: 70vh;
}

#databaseList {
    max-height: calc(70vh - 200px);
    overflow-y: auto;
}

/* Database list item hover effects */
#databaseList > div {
    transition: all 0.2s ease;
}

#databaseList > div:not([style*="background: #f0f7ff"]):hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    transform: translateY(-1px);
}

/* Mobile responsive for database switcher */
@media (max-width: 480px) {
    .current-database-indicator {
        padding: 0 15px;
    }

    #databaseSwitcherModal .modal-content {
        max-width: 95%;
    }

    #databaseList > div {
        padding: 10px;
        font-size: 12px;
    }
}

/* ========================================================================== */
/* POCKETSUITE INTEGRATION STYLES
/* ========================================================================== */

/* Payment Status Colors */
.payment-status-paid {
    color: #28a745;
    font-weight: bold;
}

.payment-status-unpaid {
    color: #dc3545;
    font-weight: bold;
}

.payment-status-pending {
    color: #ffc107;
    font-weight: bold;
}

.payment-status-unknown {
    color: #6c757d;
}

/* Import badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-info {
    background-color: #17a2b8;
    color: white;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.badge-danger {
    background-color: #dc3545;
    color: white;
}

/* Payment method icons */
.payment-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 5px;
}

/* Import status indicators */
.import-status-running {
    color: #007bff;
    font-weight: bold;
}

.import-status-completed {
    color: #28a745;
    font-weight: bold;
}

.import-status-failed {
    color: #dc3545;
    font-weight: bold;
}

.import-status-partial {
    color: #ffc107;
    font-weight: bold;
}

/* PocketSuite stat cards - special styling */
.stat-card[style*="border-left: 3px solid"] {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card[style*="border-left: 3px solid"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

/* Import management table styles */
.import-management .data-table {
    margin-top: 20px;
}

.import-management .data-table td {
    vertical-align: middle;
}

/* Payment breakdown cards */
.import-management .analytics-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.import-management .analytics-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
}
