/* ============================================
   AAscraper Dashboard — Design System
   Brandwatch-style compact UI
   ============================================ */

/* --- Variables --- */
:root {
    --bg:           #f4f5f7;
    --sidebar-bg:   #ffffff;
    --sidebar-w:    210px;
    --topbar-h:     52px;
    --card-bg:      #ffffff;
    --border:       #e2e8f0;
    --text:         #1a202c;
    --text-muted:   #64748b;
    --text-light:   #94a3b8;
    --primary:      #1e4fcc;
    --primary-light:#eff3ff;
    --success:      #2d9050;
    --success-bg:   #f0faf4;
    --warning:      #d97706;
    --danger:       #dc2626;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:       0 2px 8px rgba(0,0,0,.08);
    --radius-sm:    4px;
    --radius:       8px;
    --radius-lg:    12px;
    --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   APP SHELL
   ============================================ */
.app-hidden { opacity: 0; pointer-events: none; transform: translateY(6px); }
.app-visible {
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: opacity .6s ease, transform .6s ease;
}

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: relative;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
    display: block;
}

.brand-sub {
    font-size: 10.5px;
    color: var(--text-muted);
    display: block;
    line-height: 1;
}

/* Nav Items */
.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
    border-left-color: var(--border);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-footer-info {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.version-badge {
    font-size: 10px;
    color: var(--text-light);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 8px;
}

/* ============================================
   MAIN AREA
   ============================================ */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 5;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-range-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.date-range-chip:hover { border-color: var(--primary); color: var(--primary); }

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* ============================================
   BUTTONS
   ============================================ */
.btn-outline {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: white;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font);
    text-decoration: none;
}

.btn-primary:hover { background: #163da8; }

.btn-icon-sm {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all .15s;
    font-size: 11px;
}

.btn-icon-sm:hover { border-color: var(--danger); color: var(--danger); }
.btn-icon-sm.edit:hover { border-color: var(--primary); color: var(--primary); }

/* ============================================
   DASHBOARD SECTION
   ============================================ */

/* KPI Row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s;
}

.kpi-card:hover { box-shadow: var(--shadow); }

.kpi-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.kpi-icon.blue   { background: #eff3ff; color: #1e4fcc; }
.kpi-icon.green  { background: #f0faf4; color: #2d9050; }
.kpi-icon.orange { background: #fff7ed; color: #d97706; }
.kpi-icon.purple { background: #f5f3ff; color: #6d28d9; }

.kpi-body { display: flex; flex-direction: column; gap: 1px; }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.kpi-delta { font-size: 11.5px; font-weight: 500; }
.kpi-delta.up     { color: var(--success); }
.kpi-delta.down   { color: var(--danger); }
.kpi-delta.neutral{ color: var(--text-muted); }

/* Dashboard Card Grid */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.dash-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.dash-card.span-2 { grid-column: span 2; }

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

.card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
}

.card-title i { color: var(--primary); font-size: 12px; }
.card-meta { font-size: 11px; color: var(--text-muted); }

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.stat-label { font-size: 10.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-num   { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 10px; color: var(--text-light); }

.chart-wrap { height: 200px; }

/* Weekly Highlight Bar */
.weekly-highlight-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 10px;
    padding: 0;
}

.weekly-highlight-bar::before {
    content: '';
    display: block;
    width: 3px;
    height: 14px;
    background: var(--primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.weekly-highlight-bar::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.wh-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .08em;
    white-space: nowrap;
}

/* Notable List */
.notable-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notable-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: background .15s;
}

.notable-item:hover { background: var(--primary-light); }

.notable-rank {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 16px;
    padding-top: 1px;
}

.notable-content { flex: 1; }

.notable-title {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--primary);
    display: block;
    cursor: pointer;
    line-height: 1.4;
}

.notable-title:hover { text-decoration: underline; }

.notable-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: block;
}

.notable-reasoning {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    padding: 6px 10px;
    background: white;
    border-left: 2px solid var(--border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.reasoning-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.reasoning-text {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Context */
.context-body p {
    font-size: 13px;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 10px;
}

.topic-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.topic-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
}

/* Tag Volume Section */

.tag-filter-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: -1px; /* Align with table border */
}

.tag-toggle-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 16px;
}

.tag-chip {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    transition: all 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tag-chip.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.tag-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
}


.tag-sort-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 16px;
}

.sort-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.trend-up   { color: var(--success); font-weight: 600; font-size: 11.5px; }
.trend-down { color: var(--danger);  font-weight: 600; font-size: 11.5px; }
.trend-flat { color: var(--text-muted); font-size: 11.5px; }

.share-bar-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.share-bar-bg {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.share-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--primary);
}

/* ============================================
   DATA SECTION
   ============================================ */
.section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 7px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    min-width: 220px;
}

.search-box i { color: var(--text-muted); font-size: 12px; }

.search-box input {
    border: none;
    outline: none;
    font-size: 12.5px;
    font-family: var(--font);
    color: var(--text);
    width: 100%;
    background: transparent;
}

.select-filter {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12.5px;
    font-family: var(--font);
    background: white;
    color: var(--text);
    cursor: pointer;
    outline: none;
}

.select-filter:focus { border-color: var(--primary); }

.result-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* Table */
.table-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.data-table th {
    text-align: left;
    padding: 9px 12px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.data-table td {
    padding: 9px 12px;
    font-size: 12.5px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafbfc; }

.uid-cell {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.snippet-cell {
    max-width: 320px;
    line-height: 1.5;
    color: var(--text);
}

.source-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 3px;
    white-space: nowrap;
}

.source-badge.news    { background: #e0e7ff; color: #3730a3; }
.source-badge.social  { background: #fce7f3; color: #be185d; }
.source-badge.forum   { background: #fef3c7; color: #92400e; }
.source-badge.broadcast { background: #d1fae5; color: #065f46; }

.tag-pill {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    color: white;
    margin: 1px;
}

.btn-detail {
    padding: 4px 10px;
    font-size: 11.5px;
    font-family: var(--font);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    color: var(--primary);
    transition: all .15s;
}

.btn-detail:hover { background: var(--primary-light); border-color: var(--primary); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 14px 0;
}

.page-btn {
    min-width: 30px; height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
    color: var(--text);
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); font-weight: 600; }

/* ============================================
   CONTEXTUAL TAG SECTION
   ============================================ */
.tag-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    align-items: start;
}

.tag-form-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.tag-form-card .card-title {
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
}

.tag-form-card .card-title i { color: var(--primary); }

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

.form-group label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color .15s;
}

.form-input:focus { border-color: var(--primary); background: white; }

.color-swatches { display: flex; gap: 6px; }

.swatch {
    width: 22px; height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .15s;
}

.swatch.active { border-color: var(--text); transform: scale(1.15); }

.tag-table-area {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

/* ============================================
   REPORT SECTION
   ============================================ */
.section-title-inline {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.report-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow .2s;
}

.report-card:hover { box-shadow: var(--shadow); }

.report-icon-wrap {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}

.report-icon-wrap.pdf  { background: #fee2e2; color: #dc2626; }
.report-icon-wrap.xlsx { background: #d1fae5; color: #059669; }
.report-icon-wrap.docx { background: #e0e7ff; color: #4338ca; }
.report-icon-wrap.file { background: var(--bg); color: var(--text-muted); }

.report-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.report-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.report-card .btn-primary {
    align-self: flex-start;
    margin-top: auto;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.3);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: all .2s;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    transform: scale(.96);
    transition: transform .2s;
}

.modal-overlay.open .modal { transform: scale(1); }

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

.modal-header h3 { font-size: 14px; font-weight: 600; }

.modal-close {
    width: 28px; height: 28px; border: none; background: var(--bg);
    border-radius: var(--radius-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 13px;
    transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-field { margin-bottom: 14px; }
.modal-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 3px; }
.modal-field p { font-size: 13px; color: var(--text); line-height: 1.6; }

/* ============================================
   MENTIONS MODAL
   ============================================ */
.mentions-modal-box {
    width: 95%;
    max-width: 900px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.mention-item {
    display: flex;
    padding: 24px 32px 24px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.mention-left {
    width: 60px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mention-row-num {
    font-size: 18px;
    color: var(--text-light);
}

.mention-star {
    color: #e2e8f0;
    font-size: 12px;
    cursor: pointer;
}

.mention-publisher-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-top: 10px;
    background: var(--primary-light);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

.mention-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mention-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.mention-meta-left {
    color: var(--text);
}

.mention-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a56db;
    margin: 4px 0 8px;
    line-height: 1.4;
    cursor: pointer;
}

.mention-title:hover {
    text-decoration: underline;
}

.mention-snippet {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 16px;
}

.mention-snippet strong {
    font-weight: 700;
}

.mention-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

.mention-actions-left {
    color: #1a56db;
    cursor: pointer;
}

.mention-actions-left:hover {
    text-decoration: underline;
}

.mention-actions-expand {
    color: #1a56db;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   TOOLTIPS
   ============================================ */
.info-tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    color: var(--text-light);
    cursor: help;
    font-size: 12px;
}

.info-tooltip-wrap:hover { color: var(--primary); }

.info-tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 220px;
    background: #1e293b;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    white-space: normal;
    text-align: left;
    margin-bottom: 8px;
    text-transform: none;
    letter-spacing: normal;
}

.info-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

.info-tooltip-wrap:hover .info-tooltip-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   LOADED STATE (spinner)
   ============================================ */
.load-spinner { display: block; pointer-events: none; }

/* ============================================
   RESPONSIVE & MOBILE NAV
   ============================================ */
@media (max-width: 1023px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 210px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
        box-shadow: none;
        z-index: 10001;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }

    #menu-toggle.mobile-only {
        display: flex !important;
    }

    .main-area {
        width: 100%;
        margin-left: 0;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        backdrop-filter: blur(2px);
        z-index: 10000;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Grid Adjustments */
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .dash-grid { grid-template-columns: 1fr; }
    .dash-card.span-2 { grid-column: span 1; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .tag-layout { grid-template-columns: 1fr; }
    
    .content-area { padding: 16px 16px; }
}

@media (max-width: 640px) {
    .kpi-row { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .topbar-right .btn-outline { display: none; } /* Hide export on very small screens to save space */
}

/* ============================================
   EXECUTIVE SUMMARY — Document Style
   ============================================ */
.exsum-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
    margin-bottom: 4px;
    line-height: 1.2;
}

.exsum-period {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 0;
}

.exsum-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

.exsum-h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    padding-left: 12px;
    border-left: 3px solid var(--primary);
    line-height: 1.3;
}

.exsum-h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 20px 0 6px 0;
    text-transform: none;
    letter-spacing: 0;
}

.exsum-body {
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--text);
    margin: 0 0 4px 0;
}

.exsum-ref {
    display: inline-block;
    margin-left: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    background: var(--primary-light);
    border-radius: 3px;
    padding: 1px 7px;
    white-space: nowrap;
    transition: background .15s;
}

.exsum-ref:hover {
    background: #d6e2ff;
    text-decoration: none;
}

/* ============================================
   MVP ADDITIONS
   ============================================ */

/* Performance Grades */
.grade-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}
.grade-excellent { background: var(--success-bg); color: var(--success); }
.grade-good { background: #e0e7ff; color: #3730a3; }
.grade-average { background: #fef3c7; color: #92400e; }
.grade-poor { background: #fee2e2; color: var(--danger); }
.grade-unrated { background: var(--bg); color: var(--text-muted); }

/* Integration Cards */
.integration-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.integration-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.integration-status {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.status-connected { background: var(--success-bg); color: var(--success); }
.status-manual { background: #e0e7ff; color: #4338ca; }
.status-not_configured { background: var(--bg); color: var(--text-muted); }

.integration-capabilities {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.capability-pill {
    font-size: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
}
