/* ========================================
   India RTO Dashboard - Professional Power BI Style
   Modern, Clean, Professional Design
   ======================================== */

:root {
    /* Power BI Color Palette */
    --primary-blue: #0078d4;
    --primary-blue-hover: #106ebe;
    --success-green: #107c10;
    --warning-orange: #ff8c00;
    --error-red: #d13438;
    --purple: #8764b8;
    --pink: #e3008c;
    --teal: #00b7c3;
    
    /* Background Colors */
    --bg-primary: #f3f2f1;
    --bg-secondary: #ffffff;
    --bg-tertiary: #faf9f8;
    --bg-header: #323130;
    --bg-nav: #2b2a29;
    --bg-card: #ffffff;
    
    /* Text Colors */
    --text-primary: #323130;
    --text-secondary: #605e5c;
    --text-light: #ffffff;
    --text-muted: #8a8886;
    --text-accent: #0078d4;
    
    /* Borders & Shadows */
    --border-color: #edebe9;
    --border-light: #f3f2f1;
    --shadow-sm: 0 1.6px 3.6px rgba(0,0,0,0.13), 0 0.3px 0.9px rgba(0,0,0,0.10);
    --shadow-md: 0 3.2px 7.2px rgba(0,0,0,0.13), 0 0.6px 1.8px rgba(0,0,0,0.11);
    --shadow-lg: 0 6.4px 14.4px rgba(0,0,0,0.13), 0 1.2px 3.6px rgba(0,0,0,0.11);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

/* ========================================
   Global Styles
   ======================================== */

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* ========================================
   Header
   ======================================== */

.app-header {
    background: linear-gradient(135deg, #0078d4 0%, #106ebe 100%);
    color: var(--text-light);
    padding: 20px 32px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo-section h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    font-weight: 400;
}

.header-stats {
    display: flex;
    gap: 20px;
}

.stat-chip {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.2);
}

.stat-label {
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    font-weight: 500;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

/* ========================================
   Tab Navigation
   ======================================== */

.tab-navigation {
    background: var(--bg-secondary);
    display: flex;
    padding: 0 16px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 76px;
    z-index: 99;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 14px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
    background: var(--bg-tertiary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-blue);
}

.tab-icon {
    font-size: 14px;
}

.tab-label {
    font-weight: 500;
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 32px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.section-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========================================
   KPI Cards
   ======================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-blue);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========================================
   Charts
   ======================================== */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.chart-container {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.chart-container.full-width {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-indicator {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.chart-container canvas {
    max-height: 300px;
}

/* ========================================
   Tables
   ======================================== */

.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.table-container {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.table-container.full-width {
    grid-column: 1 / -1;
}

.table-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-blue);
}

.table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    position: sticky;
    top: 0;
    background: #faf9f8;
    z-index: 10;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    letter-spacing: 0.5px;
}

tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: #f9f8f7;
}

tbody tr.clickable {
    cursor: pointer;
}

tbody tr.clickable:hover {
    background: rgba(0,120,212,0.08);
}

tbody td {
    padding: 14px 16px;
    color: var(--text-primary);
}

tbody td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.text-right {
    text-align: right !important;
}

/* ========================================
   Filters
   ======================================== */

.filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    border: 1px solid var(--border-light);
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.filter-group.wide {
    flex: 1;
    min-width: 320px;
}

.filter-group-wide {
    min-width: 400px;
}

/* Checkbox Filter */
.checkbox-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px;
    background: #f9f9f9;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.checkbox-filter label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e1dfdd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.checkbox-filter label:hover {
    background: #f3f2f1;
    border-color: var(--primary-blue);
}

.checkbox-filter input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-blue);
}

.checkbox-filter label.checked {
    background: #e6f2ff;
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    font-weight: 600;
}


.filter-group label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-group select:hover {
    border-color: var(--primary-blue);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0,120,212,0.1);
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: 4px;
    background: #f3f2f1;
    padding: 3px;
    border-radius: 4px;
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-family: inherit;
}

.view-btn:hover {
    background: rgba(0,120,212,0.1);
    color: var(--primary-blue);
}

.view-btn.active {
    background: var(--primary-blue);
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.filter-hint {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* ========================================
   Data Management
   ======================================== */

.data-management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

.management-card {
    background: var(--bg-card);
    padding: 28px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.management-card.full-width {
    grid-column: 1 / -1;
}

.management-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.import-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    user-select: none;
}

.import-area * {
    pointer-events: none;
}

.import-area:hover {
    border-color: var(--primary-blue);
    background: #f0f8ff;
    transform: translateY(-2px);
}

.import-area.dragover {
    border-color: var(--primary-blue);
    background: #e6f2ff;
    border-style: solid;
}

.import-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.import-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.import-subtext {
    font-size: 13px;
    color: var(--text-muted);
}

.action-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-family: inherit;
    margin-bottom: 12px;
}

.action-btn.primary {
    background: var(--primary-blue);
    color: white;
}

.action-btn.primary:hover {
    background: var(--primary-blue-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn.secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.action-btn.secondary:hover {
    background: #f5f5f5;
    border-color: var(--text-secondary);
}

.action-btn.danger {
    background: var(--error-red);
    color: white;
}

.action-btn.danger:hover {
    background: #c12e32;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.4;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.stat-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-number {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.instructions {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.instructions ul {
    margin: 12px 0 16px 24px;
}

.instructions li {
    margin-bottom: 8px;
}

.instructions code {
    background: #f3f2f1;
    padding: 3px 8px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--primary-blue);
    border: 1px solid var(--border-light);
}

/* ========================================
   Progress & Status
   ======================================== */

.progress-bar {
    height: 8px;
    background: #e1e1e1;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 16px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-blue);
    width: 0%;
    transition: width 0.3s ease;
}

.status-message {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
    font-weight: 500;
}

.status-message.success {
    background: #dff6dd;
    color: var(--success-green);
    border: 1px solid #b7e4b1;
}

.status-message.error {
    background: #fde7e9;
    color: var(--error-red);
    border: 1px solid #f1aeb5;
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 2px solid var(--primary-blue);
    background: #f9f8f7;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e8e8e8;
    color: var(--text-primary);
}

.modal-body {
    padding: 28px;
}

/* ========================================
   Loading Overlay
   ======================================== */

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e1e1e1;
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

@media (max-width: 1200px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .table-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .main-content {
        padding: 20px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .tab-navigation {
        overflow-x: auto;
        padding: 0 16px;
    }
    
    .tab-btn {
        white-space: nowrap;
        padding: 14px 20px;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .data-management-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }

/* ========================================
   Market Strategy Dashboard – Sub-tabs
   ======================================== */

.cmp-sub-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.cmp-sub-tab {
    padding: 9px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary, #605e5c);
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.cmp-sub-tab:hover {
    background: #f3f2f1;
    color: var(--primary-blue, #0078d4);
}

.cmp-sub-tab.active {
    color: var(--primary-blue, #0078d4);
    border-bottom-color: var(--primary-blue, #0078d4);
    background: none;
}

.cmp-sub-content {
    display: none;
}

.cmp-sub-content.active {
    display: block;
    animation: fadeInContent 0.2s ease;
}

@keyframes fadeInContent {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* KPI strip for compare tab */
.cmp-kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.cmp-kpi-card {
    background: #fff;
    border-radius: 8px;
    padding: 14px 16px;
    border-top: 4px solid var(--primary-blue, #0078d4);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.cmp-kpi-card .kpi-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #605e5c);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.cmp-kpi-card .kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary, #323130);
}

/* Dealer-health activity filters */
.dh-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.dh-filter-btn {
    padding: 5px 14px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.dh-filter-btn:hover {
    background: #f3f2f1;
}

.dh-filter-btn.active {
    background: var(--primary-blue, #0078d4);
    color: #fff;
    border-color: var(--primary-blue, #0078d4);
}

.dh-filter-btn.active-green  { border-color: #107c10; color: #107c10; }
.dh-filter-btn.active-green.active  { background: #107c10; color: #fff; border-color: #107c10; }
.dh-filter-btn.semi-orange   { border-color: #e67e22; color: #e67e22; }
.dh-filter-btn.semi-orange.active   { background: #e67e22; color: #fff; border-color: #e67e22; }
.dh-filter-btn.inactive-red  { border-color: #d13438; color: #d13438; }
.dh-filter-btn.inactive-red.active  { background: #d13438; color: #fff; border-color: #d13438; }

/* Quick-period shortcut buttons (Last 1 / 2 / 3 Months) */
.dh-quick-btn {
    padding: 4px 14px;
    border: 1px solid #b0c4de;
    background: #fff;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #0078d4;
    cursor: pointer;
    transition: all 0.15s;
}
.dh-quick-btn:hover {
    background: #e6f2fb;
    border-color: #0078d4;
}
.dh-quick-btn.dh-quick-active {
    background: #0078d4;
    color: #fff;
    border-color: #0078d4;
}
