/* ============================================================
   XER Intelligence Platform — Premium Light Enterprise Theme v2
   ============================================================ */

/* ---- Base Container ---- */
.xer-app-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 3rem;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* ---- Header ---- */
.xer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.1rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.xer-header-left { display: flex; align-items: center; gap: 0.85rem; }
.xer-brand-icon { font-size: 2rem; flex-shrink: 0; }
.xer-brand-text h1 { font-size: 1.2rem; font-weight: 800; color: #1a202c; margin: 0; line-height: 1.3; }
.xer-brand-text p { font-size: 0.8rem; color: #718096; margin: 0; }
.xer-header-actions { display: flex; gap: 0.6rem; flex-shrink: 0; }

/* Project Info Chips */
.project-info-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.info-chip { background: #edf2f7; color: #2d3748; border-radius: 999px; padding: 0.3rem 0.9rem; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.info-chip-date { background: #e6fffa; color: #276749; }
.info-chip-count { background: #ebf8ff; color: #1565c0; }

/* ---- Upload Section ---- */
.xer-upload-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 2.5rem 2rem 2rem;
    margin-bottom: 1.25rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.upload-hero h2 { font-size: 1.4rem; font-weight: 800; color: #1a202c; margin: 0 0 0.4rem; }
.upload-hero p { color: #718096; margin: 0 0 2rem; font-size: 0.9rem; }
.upload-grid { display: flex; align-items: center; justify-content: center; gap: 1.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.upload-card {
    background: #f8fafc;
    border: 2px dashed #cbd5e0;
    border-radius: 14px;
    padding: 2rem 1.75rem;
    width: 280px;
    text-align: center;
    position: relative;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    cursor: pointer;
}
.upload-card:hover, .upload-card.dragover { border-color: #3182ce; background: #ebf8ff; transform: translateY(-2px); }
.upload-badge {
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    padding: 0.2rem 1rem; border-radius: 999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
}
.baseline-badge { background: #3182ce; color: #fff; }
.update-badge   { background: #38a169; color: #fff; }
.upload-icon { font-size: 2.25rem; margin-bottom: 0.6rem; }
.upload-card h3 { font-size: 0.95rem; color: #2d3748; margin: 0 0 0.2rem; font-weight: 700; }
.upload-card p  { font-size: 0.82rem; color: #a0aec0; margin: 0 0 1rem; }
.upload-vs { width: 42px; height: 42px; border-radius: 50%; background: #e2e8f0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #718096; font-size: 0.8rem; flex-shrink: 0; }
.hidden-input { display: none; }
.file-status { margin-top: 0.6rem; font-size: 0.8rem; font-weight: 600; min-height: 1.2rem; }
.file-status.success { color: #38a169; }
.file-status.error   { color: #e53e3e; }
.upload-actions { margin-top: 0.5rem; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.2rem; border-radius: 7px; font-size: 0.875rem; font-weight: 600; border: none; cursor: pointer; transition: all 0.18s; font-family: 'Inter',sans-serif; }
.btn-primary { background: #3182ce; color: #fff; }
.btn-primary:hover { background: #2b6cb0; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: #4a5568; border: 1.5px solid #e2e8f0; }
.btn-ghost:hover { background: #f7fafc; }
.btn-outline { background: transparent; border: 1.5px solid #3182ce; color: #3182ce; }
.btn-outline:hover { background: #ebf8ff; }
.btn-sm { padding: 0.38rem 0.85rem; font-size: 0.8rem; }
.btn-xl { padding: 0.9rem 2.75rem; font-size: 1rem; border-radius: 10px; letter-spacing: 0.01em; }
.btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ---- Filter Bar ---- */
.xer-filters-bar {
    display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.85rem;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 0.85rem 1.25rem; margin-bottom: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.filter-item { display: flex; flex-direction: column; min-width: 155px; }
.filter-item label { font-size: 0.72rem; font-weight: 700; color: #4a5568; margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Form controls */
.form-select, .form-input {
    border: 1px solid #e2e8f0; border-radius: 6px; padding: 0.48rem 0.75rem;
    font-size: 0.855rem; color: #2d3748; background: #f8fafc; font-family: 'Inter',sans-serif;
    outline: none; transition: border-color 0.15s;
}
.form-select:focus, .form-input:focus { border-color: #3182ce; background: #fff; }
textarea.form-input { resize: vertical; }

/* ---- Dashboard wrapper ---- */
.xer-dashboard { background: #f0f4f8; border-radius: 14px; overflow: hidden; }

/* ---- Tabs ---- */
.xer-tabs {
    display: flex; overflow-x: auto;
    background: #fff; border-bottom: 2px solid #e2e8f0;
    padding: 0 1rem; gap: 0;
}
.tab-btn {
    background: transparent; border: none; padding: 0.9rem 1.1rem;
    font-size: 0.875rem; font-weight: 600; color: #718096; cursor: pointer;
    border-bottom: 3px solid transparent; margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s; white-space: nowrap;
    display: flex; align-items: center; gap: 0.35rem;
}
.tab-btn:hover { color: #3182ce; }
.tab-btn.active { color: #3182ce; border-bottom-color: #3182ce; }
.tab-badge {
    background: #fed7d7; color: #9b2c2c;
    border-radius: 999px; padding: 0.05rem 0.5rem;
    font-size: 0.7rem; font-weight: 700;
}
.tab-badge--blue { background: #bee3f8; color: #1a4971; }
.tab-badge--red  { background: #fed7d7; color: #9b2c2c; }

/* ---- Tab Content ---- */
.xer-tab-content { display: none; padding: 1.25rem; }
.xer-tab-content.active { display: block; animation: xer-fade 0.2s ease; }
@keyframes xer-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- KPI Grids ---- */
.kpi-grid-8 { display: grid; grid-template-columns: repeat(8,1fr); gap: 0.85rem; margin-bottom: 0.85rem; }
.kpi-grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.85rem; margin-bottom: 1.25rem; }
.kpi-card {
    background: #fff; border-radius: 10px; padding: 1rem 1.1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); border-top: 3px solid #e2e8f0;
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.kpi-card-blue   { border-top-color: #3182ce; }
.kpi-card-green  { border-top-color: #38a169; }
.kpi-card-orange { border-top-color: #dd6b20; }
.kpi-card-red    { border-top-color: #e53e3e; }
.kpi-card-teal   { border-top-color: #319795; }
.kpi-card-purple { border-top-color: #805ad5; }
.kpi-card-gray   { border-top-color: #a0aec0; }
.kpi-icon  { font-size: 1.2rem; margin-bottom: 0.3rem; }
.kpi-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #718096; font-weight: 700; margin-bottom: 0.2rem; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: #1a202c; line-height: 1.1; margin-bottom: 0.15rem; }
.kpi-value.text-green  { color: #38a169; }
.kpi-value.text-red    { color: #e53e3e; }
.kpi-value.text-orange { color: #dd6b20; }
.kpi-sub { font-size: 0.72rem; color: #a0aec0; }
.kpi-status {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 2px 9px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 999px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.kpi-status-good   { background: #C6F6D5; color: #22543D; }
.kpi-status-warn   { background: #FEEBC8; color: #7B341E; }
.kpi-status-bad    { background: #FED7D7; color: #742A2A; }
.kpi-status-muted  { background: #E2E8F0; color: #4A5568; }

/* ---- Charts Row ---- */
.charts-row { display: grid; grid-template-columns: 270px 1fr 1fr; gap: 0.85rem; margin-bottom: 0.85rem; }
.chart-card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 1.1rem; overflow: hidden; }
.chart-title { font-size: 0.875rem; font-weight: 700; color: #2d3748; margin-bottom: 0.85rem; }
.chart-body { height: 240px; position: relative; }
.chart-body canvas { max-height: 100%; }

/* Scope Added/Deleted */
.scope-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.scope-panel { background: #fff; border-radius: 10px; padding: 1.1rem; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.scope-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.scope-header h4 { font-size: 0.875rem; font-weight: 700; color: #2d3748; margin: 0; }
.badge-pill { border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.75rem; font-weight: 700; }
.badge-green { background: #c6f6d5; color: #276749; }
.badge-red   { background: #fed7d7; color: #9b2c2c; }
.scope-list { max-height: 200px; overflow-y: auto; }
.scope-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.38rem 0; border-bottom: 1px solid #f0f4f8; font-size: 0.8rem; }
.scope-item:last-child { border-bottom: none; }
.scope-item-id { color: #3182ce; font-weight: 700; font-family: monospace; font-size: 0.78rem; flex-shrink: 0; }
.scope-item-name { color: #4a5568; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-empty { color: #a0aec0; font-size: 0.82rem; text-align: center; padding: 0.85rem; }

/* ---- Tab Panels (for grid tabs) ---- */
.tab-panel { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); overflow: hidden; }
.tab-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid #f0f4f8;
}
.tab-panel-header h3 { font-size: 0.95rem; font-weight: 700; color: #2d3748; margin: 0; }
.header-controls { display: flex; align-items: center; gap: 0.6rem; }
.search-box { min-width: 230px; }

/* ---- AG Grid Overrides ---- */
.ag-theme-alpine {
    --ag-font-family: 'Inter', sans-serif;
    --ag-font-size: 13px;
    --ag-header-background-color: #f7fafc;
    --ag-row-hover-color: #ebf8ff;
    --ag-border-color: #e8edf2;
    --ag-odd-row-background-color: #fdfdfd;
    --ag-header-foreground-color: #4a5568;
}
.status-chip { display: inline-block; padding: 0.18rem 0.55rem; border-radius: 4px; font-size: 0.74rem; font-weight: 700; }
.status-completed  { background: #c6f6d5; color: #276749; }
.status-inprogress { background: #feebc8; color: #744210; }
.status-notstarted { background: #e2e8f0; color: #4a5568; }

/* ---- DCMA Banner ---- */
.dcma-banner {
    background: #fff; border-radius: 12px; border: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 1.75rem 2rem;
    display: grid; grid-template-columns: auto 1fr auto;
    gap: 2rem; align-items: center; margin-bottom: 1.25rem;
}
.dcma-score-ring { flex-shrink: 0; }
.dcma-score-info { }
.dcma-grade { font-size: 1.6rem; font-weight: 800; color: #1a202c; margin-bottom: 0.1rem; }
.dcma-grade-sub { font-size: 0.82rem; color: #718096; margin-bottom: 0.85rem; }
.dcma-pf-row { display: flex; gap: 1.25rem; }
.dcma-pf-item { font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 0.35rem; }
.dcma-pf-item span { font-size: 1.25rem; font-weight: 800; }
.dcma-pf-item.pass { color: #38a169; }
.dcma-pf-item.warn { color: #dd6b20; }
.dcma-pf-item.fail { color: #e53e3e; }
.dcma-meta { background: #f7fafc; border-radius: 8px; padding: 1rem 1.25rem; min-width: 220px; }
.dcma-meta-row { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0; font-size: 0.82rem; border-bottom: 1px solid #edf2f7; }
.dcma-meta-row:last-child { border-bottom: none; }
.dcma-meta-row span { color: #718096; }
.dcma-meta-row strong { color: #2d3748; font-weight: 700; }

/* DCMA Checks Table */
.dcma-checks-table { width: 100%; }
.dcma-check-row {
    display: grid;
    grid-template-columns: 32px 2fr 100px 100px 1fr 100px;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    align-items: center;
    gap: 16px;
    transition: background 0.2s ease;
}
.dcma-check-row.clickable-row {
    cursor: pointer;
}
.dcma-check-row.clickable-row:hover { 
    background: #edf2f7; 
}
.dcma-check-row:not(.clickable-row):hover { background: #f7fafc; }
.dcma-check-header {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: #718096; font-weight: 700; background: #f7fafc; border-bottom: 2px solid #e2e8f0;
}
.dcma-check-num { font-weight: 700; color: #a0aec0; }
.dcma-check-name { }
.dcma-check-name strong { display: block; font-weight: 600; color: #2d3748; }
.dcma-check-name small { color: #a0aec0; font-size: 0.75rem; }
.dcma-check-target { color: #718096; font-size: 0.8rem; }
.dcma-check-value { font-weight: 700; color: #2d3748; }
.dcma-check-issues { color: #718096; font-size: 0.8rem; }
.status-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 700; }
.status-pass { background: #c6f6d5; color: #276749; }
.status-warn { background: #feebc8; color: #744210; }
.status-fail { background: #fed7d7; color: #9b2c2c; }

/* ---- Areas of Concern ---- */
.concerns-counters { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.85rem; margin-bottom: 1.25rem; }
.concern-kpi {
    background: #fff; border-radius: 10px; padding: 1.25rem 1rem; text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s; border-top: 4px solid transparent;
}
.concern-kpi:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.09); }
.concern-high     { border-top-color: #e53e3e; }
.concern-medium   { border-top-color: #dd6b20; }
.concern-low      { border-top-color: #3182ce; }
.concern-resolved { border-top-color: #38a169; }
.ckpi-icon { font-size: 1.6rem; margin-bottom: 0.4rem; }
.ckpi-val  { font-size: 2.1rem; font-weight: 800; color: #1a202c; line-height: 1; }
.ckpi-lbl  { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #718096; font-weight: 700; margin-top: 0.3rem; }

/* Concern Cards */
.concern-card {
    background: #fff; border-radius: 8px; border: 1px solid #f0f4f8;
    padding: 1.1rem 1.25rem; margin: 0.5rem 1rem;
    display: grid; grid-template-columns: 10px 1fr auto; gap: 0.85rem; align-items: start;
}
.concern-card:hover { border-color: #e2e8f0; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.concern-sev-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.sev-high     { background: #e53e3e; }
.sev-medium   { background: #dd6b20; }
.sev-low      { background: #3182ce; }
.sev-resolved { background: #38a169; }
.concern-title { font-weight: 700; color: #1a202c; margin-bottom: 0.2rem; font-size: 0.9rem; }
.concern-meta  { font-size: 0.78rem; color: #718096; display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.3rem; }
.concern-meta .sev-label { font-weight: 700; }
.concern-desc { font-size: 0.82rem; color: #4a5568; }
.concern-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
.btn-icon { background: none; border: none; cursor: pointer; color: #a0aec0; padding: 0.3rem; border-radius: 5px; font-size: 1rem; transition: color 0.15s, background 0.15s; }
.btn-icon:hover { background: #f0f4f8; color: #4a5568; }

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: #a0aec0; }
.empty-icon  { font-size: 2.75rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.875rem; margin-bottom: 1rem; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.48);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
    animation: xer-fade 0.2s ease;
}
.modal-card {
    background: #fff; border-radius: 14px; width: 560px; max-width: 95vw;
    box-shadow: 0 24px 64px rgba(0,0,0,0.22); max-height: 90vh; overflow-y: auto;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.35rem 1.6rem; border-bottom: 1px solid #e2e8f0;
}
.modal-head h3 { font-size: 1rem; font-weight: 800; color: #1a202c; margin: 0; }
.modal-x { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #a0aec0; padding: 0.25rem; border-radius: 4px; }
.modal-x:hover { color: #4a5568; background: #f0f4f8; }
.modal-body { padding: 1.35rem 1.6rem; }
.mform-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.mform-group { display: flex; flex-direction: column; }
.mform-group.full { grid-column: 1 / -1; }
.mform-group label { font-size: 0.7rem; font-weight: 800; color: #4a5568; margin-bottom: 0.3rem; letter-spacing: 0.06em; text-transform: uppercase; }
.modal-foot { padding: 1.1rem 1.6rem; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 0.6rem; }

/* ---- Utility ---- */
.hidden { display: none !important; }

/* ---- Toggle Switch ---- */
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 21px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: #cbd5e0;
    border-radius: 21px; transition: background 0.2s;
}
.toggle-slider:before {
    content: ''; position: absolute; width: 15px; height: 15px;
    background: #fff; border-radius: 50%; left: 3px; top: 3px;
    transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: #3182ce; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(17px); }

/* ---- Flow Note ---- */
.flow-note { font-size: 0.82rem; font-weight: 600; padding: 0.45rem 0.85rem; border-radius: 7px; margin-top: 0.6rem; }
.flow-note--ok   { background: #c6f6d5; color: #22543d; }
.flow-note--warn { background: #feebc8; color: #744210; }
.flow-note--idle { background: #edf2f7; color: #718096; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: #718096; background: #f7fafc; border: 1px dashed #cbd5e0; border-radius: 8px; }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state p { max-width: 400px; margin: 0 auto; line-height: 1.5; }

/* ---- Mode Hint (info banner above a tab content) ---- */
.mode-hint {
    padding: 0.6rem 0.9rem;
    background: #ebf8ff;
    color: #2c5282;
    border-left: 3px solid #3182ce;
    border-radius: 4px;
    font-size: 0.78rem;
    line-height: 1.4;
}
.mode-hint.hidden { display: none; }

/* ---- Responsive ---- */
@media (max-width: 1280px) {
    .kpi-grid-8 { grid-template-columns: repeat(4,1fr); }
    .charts-row { grid-template-columns: 1fr 1fr; }
    .chart-sm { grid-column: 1 / -1; }
    .dcma-banner { grid-template-columns: auto 1fr; }
    .dcma-meta { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
    .kpi-grid-8 { grid-template-columns: repeat(2,1fr); }
    .kpi-grid-4 { grid-template-columns: repeat(2,1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .scope-row  { grid-template-columns: 1fr; }
    .concerns-counters { grid-template-columns: repeat(2,1fr); }
    .upload-grid { flex-direction: column; }
    .xer-header { flex-wrap: wrap; }
    .dcma-banner { grid-template-columns: 1fr; text-align: center; }
    .dcma-pf-row { justify-content: center; }
}
@media (max-width: 640px) {
    .kpi-grid-8 { grid-template-columns: repeat(2,1fr); }
    .mform-row { grid-template-columns: 1fr; }
}
