
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --bg-dark: #0f111a;
    --bg-panel: #1a1d2d;
    --bg-panel-hover: #212538;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #2d3248;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --danger: #ef4444;
    
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
    --radius-lg: 16px;
    --radius-md: 10px;
}

/* Agency-style AI report */
.agency-report {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 100%;
    overflow-x: hidden;
    direction: rtl;
    text-align: right;
}

.agency-cover {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 24px;
    padding: 28px;
    border: 1px solid rgba(59, 130, 246, 0.24);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(139, 92, 246, 0.10)), var(--bg-dark);
}

.agency-cover h1 {
    margin: 8px 0 12px;
    font-size: 30px;
    line-height: 1.35;
    color: #fff;
}

.agency-cover p {
    max-width: 820px;
    color: var(--text-secondary);
    line-height: 1.8;
    text-align: right;
}

.agency-cover aside {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    border-radius: 12px;
    background: rgba(15, 17, 26, 0.64);
    border: 1px solid var(--border-color);
}

.agency-cover aside strong {
    color: #fff;
    font-size: 20px;
}

.agency-cover aside span,
.agency-eyebrow,
.agency-section-head span {
    color: var(--text-secondary);
    font-size: 13px;
}

.agency-eyebrow,
.agency-section-head span {
    letter-spacing: 0;
    text-transform: uppercase;
}

.agency-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.agency-kpi {
    min-height: 150px;
    padding: 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    display: grid;
    align-content: space-between;
    gap: 8px;
}

.agency-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}

.agency-kpi.blue .agency-kpi-icon { background: rgba(59, 130, 246, .16); color: var(--accent-blue); }
.agency-kpi.green .agency-kpi-icon { background: rgba(16, 185, 129, .16); color: var(--accent-green); }
.agency-kpi.orange .agency-kpi-icon { background: rgba(245, 158, 11, .16); color: var(--accent-orange); }
.agency-kpi.purple .agency-kpi-icon { background: rgba(139, 92, 246, .18); color: var(--accent-purple); }

.agency-kpi span {
    color: var(--text-secondary);
    font-weight: 700;
}

.agency-kpi strong {
    color: #fff;
    font-size: 28px;
    line-height: 1;
}

.agency-kpi em {
    font-style: normal;
    font-weight: 800;
}

.agency-kpi em.positive { color: var(--accent-green); }
.agency-kpi em.negative { color: var(--danger); }

.agency-platform-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 6px;
}

.agency-platform-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(59, 130, 246, .24);
    background: rgba(59, 130, 246, .10);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 800;
}

.agency-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.agency-save-btn:disabled {
    cursor: default;
    opacity: .78;
}

.agency-section {
    padding: 24px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
}

.agency-platform-section {
    border-color: rgba(59, 130, 246, .22);
}

.agency-platform-section .agency-section-head h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agency-platform-body {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr);
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}

.agency-platform-summary,
.agency-platform-proof {
    padding: 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-dark);
}

.agency-platform-summary p {
    color: var(--text-primary);
    line-height: 1.9;
    margin: 0 0 16px;
}

.agency-platform-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.agency-platform-kpi {
    min-height: 96px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(59, 130, 246, .08);
    border: 1px solid rgba(59, 130, 246, .16);
    display: grid;
    gap: 5px;
}

.agency-platform-kpi i {
    color: var(--accent-blue);
}

.agency-platform-kpi span,
.agency-platform-proof small {
    color: var(--text-secondary);
    font-size: 12px;
}

.agency-platform-kpi strong {
    color: #fff;
    font-size: 20px;
}

.agency-platform-proof h3,
.agency-platform-table h3,
.agency-final-recommendation h3 {
    margin: 0 0 12px;
    color: #fff;
    font-size: 16px;
}

.agency-mini-post {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.agency-mini-post:last-child {
    border-bottom: 0;
}

.agency-mini-post-thumb {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    background: rgba(148, 163, 184, .12);
    background-size: cover;
    background-position: center;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
}

.agency-mini-post strong {
    color: var(--text-primary);
}

.agency-mini-post p {
    margin: 4px 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 13px;
}

.agency-platform-table {
    margin-top: 14px;
}

.agency-final-recommendation {
    margin-top: 18px;
    padding: 18px;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, .28);
    background: linear-gradient(135deg, rgba(16, 185, 129, .10), rgba(59, 130, 246, .07)), var(--bg-dark);
}

.agency-final-recommendation p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.9;
}

.agency-section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    flex-direction: row-reverse;
    gap: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.agency-section-head h2,
.agency-chart-card h3 {
    margin: 0;
    color: #fff;
}

.agency-section-head h2 {
    text-align: right;
}

.agency-section-head span {
    text-align: left;
}

.agency-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.agency-chart-card {
    min-height: 320px;
    padding: 16px;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    min-width: 0;
}

.agency-chart-card.wide {
    grid-column: span 2;
}

.agency-chart-card canvas {
    width: 100% !important;
    height: 260px !important;
    margin-top: 16px;
}

.agency-integrated-story {
    display: grid;
    gap: 18px;
}

.agency-story-block {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.25fr);
    gap: 18px;
    align-items: stretch;
    padding: 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(16, 185, 129, 0.05));
    border: 1px solid var(--border-color);
    min-width: 0;
    break-inside: avoid;
    page-break-inside: avoid;
}

.agency-story-block.featured {
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.35fr);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(139, 92, 246, 0.10));
    border-color: rgba(59, 130, 246, 0.36);
}

.agency-story-copy,
.agency-story-visual {
    min-width: 0;
}

.agency-story-copy {
    display: grid;
    align-content: center;
    gap: 12px;
    padding: 4px 2px;
}

.agency-story-kicker {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}

.agency-story-copy h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(22px, 2vw, 30px);
    line-height: 1.45;
}

.agency-story-copy p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 2;
    overflow-wrap: anywhere;
}

.agency-story-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.agency-story-pill {
    display: grid;
    gap: 3px;
    min-width: 126px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
}

.agency-story-pill b {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.agency-story-pill strong {
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.agency-story-visual {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
}

.agency-story-visual h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1.5;
}

.agency-story-visual canvas {
    width: 100% !important;
    height: 300px !important;
    min-width: 0;
}

.agency-chart-empty-state {
    min-height: 220px;
    margin-top: 16px;
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    background: rgba(59, 130, 246, .07);
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    gap: 10px;
    text-align: center;
    padding: 18px;
    line-height: 1.8;
}

.agency-chart-empty-state i {
    color: var(--accent-blue);
    font-size: 24px;
}

.agency-chart-empty-state span {
    max-width: 460px;
}

.agency-chart-note {
    margin: 10px 0 0;
    color: var(--text-secondary);
    line-height: 1.75;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.agency-executive-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
    gap: 16px;
    align-items: stretch;
}

.agency-analysis-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    width: min(100%, 980px);
    margin-inline: auto;
}

.agency-ai-blocks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.agency-ai-blocks.stacked {
    grid-template-columns: 1fr;
}

.agency-ai-block {
    padding: 18px;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid rgba(59, 130, 246, .18);
    min-width: 0;
    width: 100%;
}

.agency-ai-block h3 {
    margin: 0 0 10px;
    color: #fff;
    font-size: 16px;
    text-align: right;
}

.agency-ai-block p {
    margin: 0 0 10px;
    color: var(--text-primary);
    line-height: 1.85;
    overflow-wrap: anywhere;
    text-align: right;
}

.agency-ai-block p:last-child {
    margin-bottom: 0;
}

.agency-ai-block strong {
    color: #fff;
}
.simple-digital-report .agency-cover h1 {
    max-width: 900px;
}

.simple-report-index {
    margin: 0;
    padding: 0 24px 0 0;
    display: grid;
    gap: 8px;
    color: var(--text-primary);
    line-height: 1.85;
}

.simple-report-index li::marker {
    color: var(--primary-color);
    font-weight: 800;
}

.simple-report-body .agency-ai-block {
    padding: 20px;
}

.simple-report-body .agency-ai-block h3 {
    font-size: 18px;
}

.agency-insight-grid.stacked {
    grid-template-columns: 1fr;
}

.agency-smart-comparison-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.agency-smart-platform {
    padding: 18px;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, .18);
    background: var(--bg-dark);
    min-width: 0;
}

.agency-smart-platform-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.agency-smart-platform-head span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 800;
}

.agency-smart-platform-head strong {
    color: var(--text-secondary);
    font-size: 13px;
}

.agency-smart-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.agency-smart-mode-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, .18);
    background: rgba(59, 130, 246, .06);
}

.agency-smart-mode-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agency-smart-mode-title i {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(59, 130, 246, .16);
    color: var(--accent-blue);
}

.agency-smart-mode-title h4 {
    margin: 0;
    color: #fff;
    font-size: 16px;
}

.agency-smart-mode-card p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.agency-smart-rows {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.agency-smart-row {
    min-height: 94px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(15, 17, 26, .5);
    border: 1px solid rgba(148, 163, 184, .18);
    display: grid;
    gap: 5px;
}

.agency-smart-row span,
.agency-smart-row small {
    color: var(--text-secondary);
    line-height: 1.5;
}

.agency-smart-row strong {
    color: #fff;
    font-size: 18px;
    overflow-wrap: anywhere;
}

.agency-smart-verdict {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(16, 185, 129, .09);
    border: 1px solid rgba(16, 185, 129, .18);
}

.agency-smart-verdict strong {
    color: var(--text-primary);
    line-height: 1.75;
}

.agency-smart-verdict span {
    color: var(--accent-green);
    line-height: 1.75;
    font-weight: 800;
}

.agency-card-visual {
    position: relative;
    height: 34px;
    margin: 10px 0 14px;
    border-radius: 10px;
    background: rgba(59, 130, 246, .08);
    border: 1px solid rgba(59, 130, 246, .12);
    overflow: hidden;
}

.agency-card-visual small {
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
}

.agency-card-visual span {
    display: block;
    height: 100%;
    min-width: 18%;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(59, 130, 246, .78), rgba(16, 185, 129, .68));
}

.agency-card-visual-soft span {
    width: 72%;
}

.agency-post-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.agency-post-card {
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-dark);
}

.agency-post-media {
    height: 150px;
    background-color: rgba(255,255,255,.04);
    background-size: cover;
    background-position: center;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-size: 28px;
}

.agency-post-body {
    padding: 14px;
}

.agency-post-body span {
    color: var(--accent-blue);
    font-size: 13px;
    font-weight: 800;
}

.agency-post-body p {
    color: var(--text-primary);
    line-height: 1.7;
    margin: 10px 0 14px;
    min-height: 72px;
}

.agency-post-body div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.agency-post-body b {
    color: #fff;
}

.agency-markdown {
    line-height: 1.9;
}

.agency-markdown h3,
.agency-markdown h4 {
    color: #fff;
    margin: 22px 0 10px;
}

.agency-markdown p,
.agency-markdown li {
    color: var(--text-primary);
}

.agency-markdown table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 14px 0;
}

.agency-markdown th,
.agency-markdown td {
    border: 1px solid var(--border-color);
    padding: 10px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.agency-markdown th {
    background: rgba(59, 130, 246, .12);
    color: #fff;
}

.agency-empty {
    grid-column: 1 / -1;
    color: var(--text-secondary);
    text-align: center;
    padding: 26px;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
}

.agency-report-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.btn-archive-report,
.ai-archive-warning button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, .34);
    background: linear-gradient(135deg, rgba(16, 185, 129, .96), rgba(5, 150, 105, .96));
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(16, 185, 129, .18);
    transition: transform .2s, box-shadow .2s;
}

.btn-archive-report:hover,
.ai-archive-warning button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 34px rgba(16, 185, 129, .28);
}

.ai-header-archive-btn {
    min-height: 34px;
    box-shadow: 0 8px 20px rgba(16, 185, 129, .14);
}

.ai-archive-warning {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: rgba(16, 185, 129, .11);
    border: 1px solid rgba(16, 185, 129, .28);
}

.ai-archive-warning strong,
.ai-archive-warning span {
    display: block;
}

.ai-archive-warning strong {
    color: #d1fae5;
    margin-bottom: 4px;
}

.ai-archive-warning span {
    color: #a7f3d0;
    font-size: 13px;
    line-height: 1.7;
}

.agency-insight-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.agency-insight-card {
    min-height: 160px;
    padding: 18px;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
}

.agency-insight-card span {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.agency-insight-card strong {
    display: block;
    color: #fff;
    font-size: 24px;
    margin-bottom: 12px;
}

.agency-insight-card p {
    color: var(--text-primary);
    line-height: 1.8;
    margin: 0;
}

.agency-table-grid {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.35fr);
    gap: 16px;
}

.agency-table-card {
    overflow: hidden;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 16px;
}

.agency-table-card.full {
    width: 100%;
}

.agency-table-card h3 {
    margin: 0 0 14px;
    color: #fff;
}

.agency-data-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
}

.agency-data-table th,
.agency-data-table td {
    border: 1px solid var(--border-color);
    padding: 11px 12px;
    text-align: right;
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.agency-data-table th {
    background: rgba(59, 130, 246, .14);
    color: #fff;
}

.agency-data-table td {
    color: var(--text-primary);
}

.agency-data-table td small {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.4;
}

.agency-post-index {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agency-post-index > span {
    width: 20px;
    flex: 0 0 20px;
    font-weight: 800;
    color: var(--text-secondary);
}

.agency-table-thumb {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 8px;
    background-color: rgba(148, 163, 184, .12);
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
    display: grid;
    place-items: center;
    color: var(--text-secondary);
}

.latest-posts-table th:nth-child(4),
.latest-posts-table td:nth-child(4),
.recommendations-table th:nth-child(4),
.recommendations-table td:nth-child(4) {
    width: 34%;
}

.agency-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(139, 92, 246, .16);
    color: #c4b5fd;
    font-weight: 800;
}

.agency-observation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.agency-recommendation-insights {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.agency-recommendation-insights .agency-observation-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, .08), rgba(59, 130, 246, .06)), var(--bg-dark);
    border-color: rgba(16, 185, 129, .22);
}

.agency-observation-card {
    min-width: 0;
    padding: 18px;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
}

.agency-observation-card h3 {
    margin: 0 0 10px;
    color: #fff;
    font-size: 17px;
}

.agency-observation-card p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.85;
    overflow-wrap: anywhere;
}

.exported-chart-image {
    width: 100%;
    height: auto;
    display: block;
    margin-top: 16px;
}

.platform-placeholder {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.platform-hero {
    min-height: 230px;
    padding: 28px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.platform-hero div {
    max-width: 760px;
}

.platform-hero i {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    margin-bottom: 16px;
    font-size: 26px;
    background: rgba(255,255,255,.08);
}

.x-platform-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 5px;
    display: inline-grid;
    place-items: center;
    color: #0f111a;
    background: #f8fafc;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    font-style: normal;
    box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.12), 0 6px 14px rgba(0, 0, 0, 0.18);
}

.x-platform-icon::before {
    content: 'X';
}

.platform-hero .x-platform-icon.hero-icon,
.platform-hero i.x-platform-icon {
    width: 62px;
    height: 62px;
    min-width: 62px;
    border-radius: 16px;
    margin-bottom: 16px;
    font-size: 30px;
    color: #0f111a;
    background: linear-gradient(135deg, #f8fafc, #cbd5e1);
    box-shadow: 0 14px 36px rgba(226, 232, 240, 0.14), inset 0 0 0 1px rgba(15, 17, 26, 0.08);
}

.platform-hero h2 {
    margin: 0 0 10px;
    color: #fff;
    font-size: 30px;
}

.platform-hero p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0;
}

.platform-hero > span {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(16, 185, 129, .14);
    color: var(--accent-green);
    font-weight: 800;
    border: 1px solid rgba(16, 185, 129, .28);
}

.platform-hero.linkedin { border-color: rgba(10, 102, 194, .45); }
.platform-hero.twitter { border-color: rgba(226, 232, 240, .30); }
.platform-hero.tiktok { border-color: rgba(56, 189, 248, .45); }
.platform-hero.snapchat { border-color: rgba(250, 204, 21, .45); }
.platform-hero.youtube { border-color: rgba(239, 68, 68, .45); }

.platform-hero.linkedin i { color: #0a66c2; background: rgba(10, 102, 194, .14); }
.platform-hero.twitter i:not(.x-platform-icon) { color: #e2e8f0; background: rgba(226, 232, 240, .10); }
.platform-hero.tiktok i { color: #38bdf8; background: rgba(56, 189, 248, .14); }
.platform-hero.snapchat i { color: #facc15; background: rgba(250, 204, 21, .14); }
.platform-hero.youtube i { color: #ef4444; background: rgba(239, 68, 68, .14); }

.platform-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.platform-metric {
    min-height: 130px;
    padding: 18px;
    border-radius: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.platform-metric b {
    color: #fff;
    font-size: 18px;
}

.platform-metric span {
    color: var(--text-secondary);
    line-height: 1.7;
}

@media (max-width: 1200px) {
    .agency-kpi-grid,
    .agency-post-grid,
    .agency-insight-grid,
    .agency-observation-grid,
    .agency-recommendation-insights,
    .agency-smart-mode-grid,
    .platform-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .agency-table-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .agency-cover,
    .agency-chart-grid,
    .agency-executive-grid,
    .agency-ai-blocks,
    .agency-platform-body,
    .agency-observation-grid,
    .agency-recommendation-insights,
    .agency-smart-mode-grid,
    .agency-smart-rows {
        grid-template-columns: 1fr;
    }

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

    .agency-kpi-grid,
    .agency-post-grid,
    .agency-insight-grid,
    .agency-platform-kpi-grid,
    .agency-observation-grid,
    .agency-recommendation-insights,
    .platform-metric-grid {
        grid-template-columns: 1fr;
    }

    .agency-section,
    .agency-cover,
    .agency-chart-card,
    .agency-table-card,
    .agency-ai-block,
    .agency-smart-platform,
    .agency-smart-mode-card,
    .agency-observation-card {
        padding: 16px;
    }

    .agency-smart-platform-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .agency-data-table th,
    .agency-data-table td {
        padding: 9px 8px;
        font-size: 12px;
    }

    .platform-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .agency-mini-post {
        grid-template-columns: 58px minmax(0, 1fr);
    }

    .agency-mini-post-thumb {
        width: 58px;
        height: 58px;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    display: flex;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}
.brand {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand i { color: var(--accent-blue); }

.brand-mark {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
    filter: drop-shadow(0 8px 18px rgba(59, 130, 246, .24));
}

.brand span {
    line-height: 1;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    text-align: right;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}
.nav-item:hover {
    background: var(--bg-panel-hover);
    color: #fff;
}
.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-right: 3px solid var(--accent-blue);
}

.user-profile {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
}
.user-info h4 { font-size: 14px; margin-bottom: 2px; }
.user-info span { font-size: 12px; color: var(--text-secondary); }

.logout-btn {
    width: 100%;
    min-height: 52px;
    margin-top: 16px;
    padding: 14px 18px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 800;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
}
.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.55);
    transform: translateY(-1px);
}

body.light-theme .logout-btn {
    background: #fff1f2;
    color: #dc2626;
    border-color: #fecaca;
    box-shadow: 0 10px 26px rgba(239, 68, 68, 0.12);
}

body.dark-theme .logout-btn {
    background: rgba(239, 68, 68, 0.14);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.35);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: 280px; /* Leave space for sidebar */
    padding: 30px 40px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: var(--bg-panel);
    padding: 20px 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}
.page-titles h1 { font-size: 24px; margin-bottom: 5px; }
.page-titles p { color: var(--text-secondary); font-size: 14px; }

.controls-group {
    display: flex;
    gap: 15px;
    align-items: center;
}
.control-select {
    background: var(--bg-dark);
    color: #fff;
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    cursor: pointer;
}
.btn-primary {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}
.btn-primary:hover { background: #2563eb; }
.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-outline:hover { background: var(--bg-panel-hover); }

/* Dashboard Grid (Kanban style) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.widget {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}
.widget:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.1);
}
.widget.span-2 { grid-column: span 2; }
.widget.span-3 { grid-column: span 3; }
.widget.span-4 { grid-column: span 4; }

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}
.widget-title {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 600;
}
.widget-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.widget-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.widget-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.widget-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.widget-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }

.widget-value {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 5px;
}
.widget-trend {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 15px;
}
.widget-trend.positive { color: var(--accent-green); }
.widget-trend.negative { color: var(--danger); }

.widget-chart-container {
    flex: 1;
    position: relative;
    min-height: 80px;
    width: 100%;
}
.widget-chart-container.large {
    min-height: 250px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: right;
    padding: 15px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}
.data-table td {
    padding: 15px;
    border-bottom: 1px solid rgba(45, 50, 72, 0.5);
    font-size: 14px;
    vertical-align: middle;
}
.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
    background:
        linear-gradient(135deg, rgba(59, 130, 246, .13), transparent 34%),
        linear-gradient(315deg, rgba(16, 185, 129, .10), transparent 34%),
        var(--bg-dark);
    overflow: hidden;
}

.login-shell {
    width: min(1180px, 100%);
    min-height: min(720px, calc(100vh - 84px));
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 0;
    direction: rtl;
    border-radius: 28px;
    border: 1px solid rgba(148, 163, 184, .18);
    background: rgba(26, 29, 45, .78);
    box-shadow: 0 34px 90px rgba(0, 0, 0, .38);
    overflow: hidden;
    backdrop-filter: blur(18px);
}

.login-form-panel {
    background: var(--bg-panel);
    padding: 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 1px solid var(--border-color);
}

.login-brand-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 42px;
}

.login-brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    font-size: 22px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    box-shadow: 0 14px 32px rgba(59, 130, 246, .28);
}

.login-brand-mark img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 10px 22px rgba(45, 212, 191, .20));
}

.login-brand-row strong {
    display: block;
    color: var(--text-primary);
    font-size: 24px;
    line-height: 1.2;
}

.login-brand-row span,
.login-eyebrow {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
}

.login-copy {
    margin-bottom: 28px;
}

.login-eyebrow {
    display: inline-flex;
    margin-bottom: 12px;
    color: var(--accent-blue);
}

.login-copy h1 {
    margin: 0 0 12px;
    color: var(--text-primary);
    font-size: clamp(28px, 3vw, 38px);
    line-height: 1.35;
    letter-spacing: 0;
}

.login-copy p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 15px;
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form .form-group {
    margin-bottom: 0;
}

.login-form .form-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 9px;
    color: var(--text-primary);
    font-weight: 800;
}

.login-input-wrap {
    position: relative;
}

.login-input-wrap > i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.login-input-wrap .form-control {
    height: 56px;
    padding: 14px 46px 14px 50px;
    border-radius: 14px;
    background: rgba(15, 17, 26, .72);
    border-color: rgba(148, 163, 184, .22);
    font-size: 15px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.login-input-wrap .form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, .14);
}

.login-eye-btn {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.login-eye-btn:hover {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, .10);
}

.login-error {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    font-size: 14px;
    background: rgba(239, 68, 68, .10);
    border: 1px solid rgba(239, 68, 68, .22);
    padding: 12px;
    border-radius: 12px;
}

.login-submit {
    width: 100%;
    height: 56px;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    box-shadow: 0 16px 34px rgba(59, 130, 246, .28);
}

.login-security-note {
    margin-top: 22px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-radius: 12px;
    background: rgba(16, 185, 129, .10);
    color: var(--text-secondary);
    font-size: 13px;
}

.login-security-note i {
    color: var(--accent-green);
}

.login-visual-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 26px;
    padding: 46px;
    background:
        linear-gradient(135deg, rgba(59, 130, 246, .18), rgba(139, 92, 246, .10)),
        var(--bg-dark);
    overflow: hidden;
}

.login-visual-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, .075) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .075) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
    pointer-events: none;
}

.login-visual-head,
.login-dashboard-visual,
.login-feature-grid {
    position: relative;
    z-index: 1;
}

.login-visual-head span {
    color: var(--accent-green);
    font-size: 13px;
    font-weight: 900;
}

.login-hero-logo {
    width: min(360px, 100%);
    max-height: 290px;
    object-fit: contain;
    object-position: right center;
    display: block;
    margin: 0 0 20px auto;
    border-radius: 20px;
    box-shadow: 0 22px 48px rgba(15, 23, 42, .26);
}

.login-visual-head h2 {
    margin: 10px 0 12px;
    color: #fff;
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.25;
    letter-spacing: 0;
    max-width: 760px;
}

.login-visual-head p {
    max-width: 680px;
    margin: 0;
    color: #b7c4d8;
    line-height: 1.8;
}

.login-dashboard-visual {
    width: min(680px, 100%);
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, .20);
    background: rgba(15, 17, 26, .64);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .30);
    padding: 20px;
}

.visual-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.visual-toolbar span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-blue);
}

.visual-toolbar span:nth-child(2) { background: var(--accent-orange); }
.visual-toolbar span:nth-child(3) { background: var(--accent-green); }
.visual-toolbar strong {
    margin-right: auto;
    font-size: 12px;
    color: var(--text-secondary);
}

.visual-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.visual-kpi-grid div,
.visual-report-card,
.login-feature-grid div {
    border: 1px solid rgba(148, 163, 184, .18);
    background: rgba(26, 29, 45, .76);
    border-radius: 16px;
}

.visual-kpi-grid div {
    display: grid;
    gap: 6px;
    padding: 14px;
}

.visual-kpi-grid i {
    color: var(--accent-blue);
}

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

.visual-kpi-grid strong {
    color: #fff;
    font-size: 22px;
}

.visual-chart-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 14px;
    margin-top: 14px;
}

.visual-line-chart {
    min-height: 190px;
    display: flex;
    align-items: end;
    gap: 10px;
    padding: 20px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(59, 130, 246, .10), rgba(16, 185, 129, .05));
    border: 1px solid rgba(148, 163, 184, .16);
}

.visual-line-chart span {
    flex: 1;
    height: var(--h);
    min-height: 22px;
    border-radius: 999px 999px 6px 6px;
    background: linear-gradient(180deg, #60a5fa, #10b981);
}

.visual-donut {
    min-height: 190px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    border-radius: 18px;
    background:
        radial-gradient(circle at center, rgba(15, 17, 26, .96) 0 50%, transparent 51%),
        conic-gradient(var(--accent-green) 0 86%, rgba(148, 163, 184, .18) 86% 100%);
    border: 1px solid rgba(148, 163, 184, .16);
}

.visual-donut strong {
    color: #fff;
    font-size: 26px;
}

.visual-donut small {
    color: var(--text-secondary);
}

.visual-report-card {
    margin-top: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.visual-report-card i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
}

.visual-report-card strong,
.login-feature-grid strong {
    display: block;
    color: var(--text-primary);
}

.visual-report-card span,
.login-feature-grid span {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.login-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.login-feature-grid div {
    padding: 16px;
}

.login-feature-grid i {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border-radius: 11px;
    color: var(--accent-green);
    background: rgba(16, 185, 129, .12);
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-secondary); }
.form-control {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: #fff;
    border-radius: var(--radius-md);
    outline: none;
}
.form-control:focus { border-color: var(--accent-blue); }

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.badge-green { background: rgba(16,185,129,0.15); color: var(--accent-green); }

.print-meta { display: none; }

@media print {
    body, .main-content { background: #fff !important; color: #000 !important; margin: 0 !important; padding: 0 !important; }
    .sidebar, .top-bar { display: none !important; }
    .widget { border: 1px solid #ccc !important; box-shadow: none !important; background: #fff !important; break-inside: avoid; }
    .widget-value { color: #000 !important; }
    .widget-title { color: #333 !important; }
    .print-meta { display: block !important; text-align: center; margin-bottom: 20px; color: #555; }
}

@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); }
    .widget.span-4 { grid-column: span 2; }
    .paid-campaign-fields,
    .campaign-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .main-content { margin-right: 0; padding: 15px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .widget.span-2, .widget.span-3, .widget.span-4 { grid-column: span 1; }
    .controls-group { flex-wrap: wrap; }
    .paid-campaigns-head {
        flex-direction: column;
    }
    .paid-campaign-fields,
    .campaign-summary-grid {
        grid-template-columns: 1fr;
    }
    .paid-campaign-notes-label {
        grid-column: auto;
    }
}

/* Post Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 17, 26, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-panel);
    width: 90%;
    max-width: 900px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}
.table-row-clickable {
    cursor: pointer;
    transition: background 0.2s;
}
.table-row-clickable:hover td {
    background: rgba(59, 130, 246, 0.1) !important;
}
@media (max-width: 768px) {
    .modal-body { flex-direction: column; }
}

/* Unified Social Connection Settings */
.settings-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 18px;
    margin-bottom: 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.settings-toolbar h3 {
    margin: 0 0 6px;
    font-size: 18px;
    color: var(--text-primary);
}
.settings-toolbar p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}
.settings-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.settings-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.35);
}
.settings-clients-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}
.settings-clients-table th,
.settings-clients-table td {
    padding: 14px 16px;
    text-align: right;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    vertical-align: middle;
}
.settings-clients-table th {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.03);
}
.settings-clients-table tr:last-child td { border-bottom: none; }
.client-table-name {
    color: var(--text-primary);
    font-weight: 800;
    margin-bottom: 4px;
}
.client-table-id {
    color: var(--text-secondary);
    font-size: 12px;
    direction: ltr;
    text-align: right;
}
.platform-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(115px, 1fr));
    gap: 8px;
}
.platform-status-pill,
.client-mode-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid transparent;
    white-space: nowrap;
}
.platform-status-pill.connected {
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.25);
}
.platform-status-pill.pending {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.16);
}
.client-mode-pill.live {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.28);
}
.client-mode-pill.demo {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.28);
}
.settings-table-actions {
    display: flex;
    gap: 8px;
}
.icon-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-dark);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.icon-action-btn:hover {
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.45);
}
.icon-action-btn.danger:hover {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.45);
}
.settings-empty-state {
    text-align: center !important;
    color: var(--text-secondary);
    padding: 28px !important;
}
.settings-save-btn {
    margin-top: 18px;
    margin-inline-start: auto;
}
.client-settings-backdrop {
    z-index: 10000;
}
.client-settings-modal {
    max-width: 1040px;
    padding: 26px;
}
.oauth-apps-modal {
    max-width: 1120px;
}
.client-settings-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding-left: 44px;
    margin-bottom: 18px;
}
.client-settings-head h2 {
    margin: 0 0 6px;
    color: var(--text-primary);
    font-size: 24px;
}
.client-settings-head p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}
.client-settings-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.24);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.client-settings-section {
    padding: 16px;
    margin-bottom: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.36);
}
.client-settings-section.compact {
    margin-bottom: 0;
}
.client-settings-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    color: var(--text-primary);
    font-size: 16px;
}
.platform-connect-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.10));
    border: 1px solid rgba(96, 165, 250, 0.22);
}
.platform-connect-row strong {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
    margin-bottom: 4px;
}
.platform-connect-row span {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}
.platform-connect-row small {
    display: block;
    color: #93c5fd;
    font-size: 11px;
    line-height: 1.6;
    margin-top: 4px;
}
.platform-connect-row.not-configured {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.16);
}
.platform-connect-row.not-configured small {
    color: #fbbf24;
}
.oauth-connect-btn {
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(59, 130, 246, 0.16);
    color: #bfdbfe;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.oauth-connect-btn:hover {
    transform: translateY(-1px);
    color: #ffffff;
    border-color: rgba(96, 165, 250, 0.55);
    background: rgba(59, 130, 246, 0.28);
}
.oauth-connect-btn:disabled {
    cursor: not-allowed;
    transform: none;
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.10);
    border-color: rgba(148, 163, 184, 0.18);
    opacity: 0.85;
}
.settings-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.settings-form-grid .form-group {
    margin-bottom: 0;
}
.settings-form-grid .span-2 {
    grid-column: span 2;
}
.client-settings-platforms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.oauth-apps-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.oauth-app-card {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.36);
}
.oauth-app-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.oauth-app-card-head h3 {
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}
.oauth-app-state {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}
.oauth-app-state.ready {
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.24);
}
.oauth-app-state.pending {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.24);
}
.oauth-copy-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.oauth-copy-row .form-control {
    flex: 1;
}
.ltr-input {
    direction: ltr;
    text-align: left;
}
.settings-switch {
    grid-column: span 2;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 700;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.settings-switch input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}
.client-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}
.client-modal-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.client-modal-form-card h4 {
    margin: 0 0 6px;
    color: var(--text-primary);
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
.client-modal-form-card label {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 13px;
}
.client-modal-field-note {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}
.paid-campaigns-card {
    grid-column: 1 / -1;
}
.paid-campaigns-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.paid-campaigns-head small {
    display: block;
    color: var(--text-secondary);
    line-height: 1.6;
}
.oauth-save-config-btn.compact {
    width: auto;
    min-height: 40px;
    padding: 9px 14px;
    white-space: nowrap;
}
.paid-campaigns-list {
    display: grid;
    gap: 14px;
}
.paid-campaign-row {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    background: var(--bg-panel);
}
.paid-campaign-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.paid-campaign-row-head strong {
    color: var(--text-primary);
}
.icon-action-btn.danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.28);
}
.paid-campaign-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.paid-campaign-fields label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.paid-campaign-notes-label {
    grid-column: span 2;
}
.paid-campaign-notes {
    min-height: 74px;
    resize: vertical;
}
.campaign-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.campaign-summary-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    background: var(--bg-card);
}
.campaign-summary-card span,
.campaign-summary-card small {
    display: block;
    color: var(--text-secondary);
    line-height: 1.5;
}
.campaign-summary-card strong {
    display: block;
    margin: 8px 0 4px;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 900;
}
.agency-campaign-story {
    border: 1px solid rgba(16, 185, 129, 0.28);
    background: rgba(16, 185, 129, 0.10);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 16px;
    line-height: 1.9;
    margin-bottom: 16px;
}
.campaign-table td strong,
.campaign-table td small {
    display: block;
}
.campaign-table td small {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}
.light-theme .paid-campaign-row,
.light-theme .campaign-summary-card {
    background: #f8fafc;
}
.light-theme .agency-campaign-story {
    background: #ecfdf5;
    color: #065f46;
    border-color: #bbf7d0;
}

.paid-campaigns-dashboard {
    display: grid;
    gap: 22px;
}

.paid-dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

.paid-dashboard-hero h2 {
    margin: 8px 0 10px;
    color: var(--text-primary);
    font-size: 28px;
    line-height: 1.4;
}

.paid-dashboard-hero p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.9;
}

.paid-dashboard-badge {
    width: 128px;
    min-height: 112px;
    border-radius: 16px;
    border: 1px solid rgba(59, 130, 246, 0.28);
    background: rgba(59, 130, 246, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.paid-dashboard-badge strong {
    font-size: 34px;
    line-height: 1;
}

.paid-dashboard-badge span {
    margin-top: 8px;
    color: var(--text-secondary);
    font-weight: 800;
}

.paid-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.paid-dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.paid-dashboard-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.14);
    color: var(--accent-blue);
}

.paid-dashboard-card span,
.paid-dashboard-card small {
    color: var(--text-secondary);
    line-height: 1.5;
}

.paid-dashboard-card strong {
    color: var(--text-primary);
    font-size: 26px;
    line-height: 1.25;
}

.paid-dashboard-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 22px;
}

.paid-dashboard-section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.paid-dashboard-section-head h2 {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.4;
}

.paid-campaign-list {
    display: grid;
    gap: 14px;
}

.paid-campaign-item {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.paid-campaign-item:hover {
    border-color: rgba(59, 130, 246, 0.55);
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
}

.paid-campaign-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.paid-campaign-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-weight: 800;
    cursor: pointer;
}

.paid-campaign-select input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.paid-campaign-details-btn {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 13px;
}

.paid-campaign-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: rgba(59, 130, 246, 0.08);
}

.paid-campaign-toolbar strong,
.paid-campaign-toolbar span {
    display: block;
}

.paid-campaign-toolbar strong {
    color: var(--text-primary);
    font-size: 24px;
    line-height: 1.2;
}

.paid-campaign-toolbar span {
    color: var(--text-secondary);
}

.paid-campaign-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.paid-campaign-rank {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: rgba(139, 92, 246, 0.14);
    color: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.paid-campaign-main h3 {
    margin: 0 0 6px;
    color: var(--text-primary);
    line-height: 1.4;
}

.paid-campaign-main p {
    margin: 0 0 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.paid-progress {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    overflow: hidden;
}

.paid-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: inherit;
}

.paid-campaign-metrics {
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.paid-campaign-metrics span {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.paid-campaign-metrics b,
.paid-campaign-metrics small {
    display: block;
}

.paid-campaign-metrics b {
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.35;
}

.paid-campaign-metrics small {
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

.paid-dashboard-empty {
    background: var(--bg-panel);
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    padding: 38px 24px;
    text-align: center;
    display: grid;
    justify-items: center;
    gap: 14px;
}

.paid-dashboard-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: rgba(59, 130, 246, 0.14);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.paid-dashboard-empty h3 {
    margin: 0;
    color: var(--text-primary);
}

.paid-dashboard-empty p {
    margin: 0;
    max-width: 760px;
    color: var(--text-secondary);
    line-height: 1.9;
}

.paid-dashboard-error {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 820px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.32);
    background: rgba(239, 68, 68, 0.10);
    color: var(--danger);
    line-height: 1.7;
    font-weight: 800;
}

.light-theme .paid-dashboard-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.paid-campaign-modal-backdrop {
    z-index: 10050;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.paid-campaign-modal-content {
    width: min(1320px, 96vw);
    max-height: 92vh;
    overflow-y: auto;
    padding: 26px;
}

.paid-campaign-modal-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 18px;
}

.paid-campaign-modal-header h2 {
    margin: 6px 0;
    color: var(--text-primary);
    line-height: 1.4;
}

.paid-campaign-modal-header p {
    margin: 0;
    color: var(--text-secondary);
}

.paid-campaign-modal-body {
    display: grid;
    gap: 18px;
}

.paid-detail-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 20px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
}

.paid-detail-hero h3 {
    margin: 6px 0 10px;
    color: var(--text-primary);
    font-size: 24px;
    line-height: 1.45;
}

.paid-detail-hero p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.9;
}

.paid-detail-status {
    min-width: 118px;
    padding: 12px 16px;
    border-radius: 999px;
    text-align: center;
    border: 1px solid rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    font-weight: 900;
}

.paid-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.paid-detail-metric {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.paid-detail-metric span,
.paid-detail-metric small {
    display: block;
    color: var(--text-secondary);
    line-height: 1.5;
}

.paid-detail-metric strong {
    display: block;
    margin: 8px 0 4px;
    color: var(--text-primary);
    font-size: 24px;
    line-height: 1.25;
}

.paid-detail-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.paid-detail-chart-card {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
}

.paid-detail-chart-card h4 {
    margin: 0 0 12px;
    color: var(--text-primary);
}

.paid-detail-chart-card > div {
    height: 300px;
}

.paid-detail-chart-card:nth-child(3) {
    grid-column: 1 / -1;
}

.paid-detail-two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.paid-detail-panel {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
}

.paid-detail-panel h4 {
    margin: 0 0 14px;
    color: var(--text-primary);
}

.paid-detail-table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 12px;
}

.paid-detail-table th,
.paid-detail-table td {
    border: 1px solid var(--border-color);
    padding: 11px 12px;
    color: var(--text-primary);
    text-align: right;
    vertical-align: top;
}

.paid-detail-table th {
    color: var(--text-secondary);
    background: rgba(148, 163, 184, 0.08);
    font-weight: 900;
}

.paid-detail-empty {
    padding: 20px;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.paid-selected-report .agency-section {
    overflow-x: hidden;
}

.paid-material-section {
    display: grid;
    gap: 16px;
}

.paid-material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.paid-material-card {
    display: grid;
    grid-template-columns: 96px 1fr;
    min-height: 132px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.paid-material-preview {
    min-height: 132px;
    background-color: rgba(59, 130, 246, 0.12);
    background-size: cover;
    background-position: center;
}

.paid-material-preview.empty {
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: 28px;
}

.paid-material-body {
    display: grid;
    gap: 8px;
    padding: 12px;
    min-width: 0;
}

.paid-material-body span,
.paid-material-body p,
.paid-material-metrics small {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
}

.paid-material-body h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
}

.paid-material-body p {
    margin: 0;
}

.paid-material-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.paid-material-metrics small {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.10);
}

.paid-material-metrics b {
    color: var(--text-primary);
    font-size: 12px;
}

.paid-selected-cover {
    align-items: center;
}

.paid-dashboard-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.light-theme .paid-dashboard-hero,
.light-theme .paid-dashboard-section,
.light-theme .paid-dashboard-empty {
    background: #ffffff;
}

.light-theme .paid-dashboard-card,
.light-theme .paid-campaign-item,
.light-theme .paid-campaign-metrics span,
.light-theme .paid-detail-metric,
.light-theme .paid-detail-chart-card,
.light-theme .paid-detail-panel {
    background: #f8fafc;
}

.light-theme .paid-campaign-toolbar,
.light-theme .paid-detail-hero {
    background: #eff6ff;
}

@media (max-width: 1100px) {
    .paid-dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .paid-campaign-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .paid-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .paid-material-card {
        grid-template-columns: 1fr;
    }

    .paid-material-preview {
        min-height: 180px;
    }

    .paid-detail-charts,
    .paid-detail-two-col {
        grid-template-columns: 1fr;
    }

    .paid-detail-chart-card:nth-child(3) {
        grid-column: auto;
    }
}

@media (max-width: 720px) {
    .paid-dashboard-hero {
        grid-template-columns: 1fr;
    }

    .paid-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .paid-campaign-item {
        grid-template-columns: 1fr;
    }

    .paid-campaign-metrics {
        grid-column: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .paid-campaign-toolbar,
    .paid-detail-hero {
        grid-template-columns: 1fr;
    }

    .paid-campaign-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .paid-campaign-toolbar-actions {
        flex-direction: column;
    }

    .paid-detail-grid {
        grid-template-columns: 1fr;
    }

    .paid-campaign-modal-backdrop {
        padding: 12px;
    }
}
.oauth-inline-connect-btn {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}
.oauth-inline-connect-btn:hover {
    border-color: rgba(59, 130, 246, 0.75);
    background: rgba(59, 130, 246, 0.2);
}
.x-oauth-config-box {
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.28);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.x-oauth-config-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-primary);
}
.oauth-save-config-btn {
    min-height: 38px;
    border: 1px solid rgba(16, 185, 129, 0.32);
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border-radius: 9px;
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    cursor: pointer;
}
.light-theme .oauth-inline-connect-btn {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}
.light-theme .x-oauth-config-box {
    background: #f8fafc;
    border-color: #dbeafe;
}
.light-theme .oauth-save-config-btn {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}
.x-platform-badge {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: #ffffff;
    color: #020617;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: 900;
}
.light-theme .settings-toolbar,
.light-theme .client-settings-section,
.light-theme .settings-table-wrap,
.light-theme .oauth-app-card,
.light-theme .client-modal-form-card {
    background: #f8fafc;
}
.light-theme .platform-connect-row {
    background: #eef6ff;
    border-color: #bfdbfe;
}
.light-theme .platform-connect-row.not-configured {
    background: #f8fafc;
    border-color: #e2e8f0;
}
.light-theme .platform-connect-row small {
    color: #2563eb;
}
.light-theme .platform-connect-row.not-configured small {
    color: #b45309;
}
.light-theme .oauth-connect-btn {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}
.light-theme .oauth-connect-btn:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}
.light-theme .oauth-connect-btn:disabled {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #64748b;
}
.light-theme .icon-action-btn,
.light-theme .settings-switch {
    background: #ffffff;
}

@media (max-width: 900px) {
    .settings-toolbar,
    .client-settings-head {
        flex-direction: column;
    }
    .settings-toolbar .btn-primary,
    .settings-toolbar-actions,
    .settings-save-btn {
        width: 100%;
        justify-content: center;
    }
    .settings-toolbar-actions .btn-primary,
    .settings-toolbar-actions .btn-outline {
        width: 100%;
        justify-content: center;
    }
    .client-settings-platforms,
    .oauth-apps-grid,
    .settings-form-grid {
        grid-template-columns: 1fr;
    }
    .settings-form-grid .span-2,
    .settings-switch {
        grid-column: auto;
    }
    .platform-connect-row {
        flex-direction: column;
        align-items: stretch;
    }
    .oauth-connect-btn {
        width: 100%;
    }
    .client-settings-modal {
        width: 94%;
        padding: 22px 16px;
    }
}

/* Theme reliability layer: one source of truth for pages, cards, modals, and empty states */
body.dark-theme {
    --bg-dark: #0f111a;
    --bg-panel: #1a1d2d;
    --bg-panel-hover: #24283b;
    --bg-card: #171b2b;
    --bg-elevated: #202437;
    --text-primary: #f8fafc;
    --text-secondary: #b7c4d8;
    --text-muted: #8ea0b8;
    --border-color: #313850;
    --input-bg: #0f1320;
    --input-text: #f8fafc;
    --empty-bg: rgba(59, 130, 246, 0.09);
    --empty-border: rgba(96, 165, 250, 0.24);
    --modal-overlay: rgba(5, 8, 18, 0.78);
    --row-hover: rgba(255, 255, 255, 0.035);
    --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.35);
}

body.light-theme {
    --bg-dark: #eef3f8;
    --bg-panel: #ffffff;
    --bg-panel-hover: #f3f7fb;
    --bg-card: #f8fbff;
    --bg-elevated: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #d7e0ea;
    --input-bg: #ffffff;
    --input-text: #0f172a;
    --empty-bg: #f1f7ff;
    --empty-border: #bfdbfe;
    --modal-overlay: rgba(15, 23, 42, 0.52);
    --row-hover: rgba(37, 99, 235, 0.045);
    --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body.dark-theme,
body.light-theme,
body.dark-theme .main-content,
body.light-theme .main-content,
body.dark-theme .login-page,
body.light-theme .login-page {
    background: var(--bg-dark) !important;
    color: var(--text-primary) !important;
}

body.dark-theme .sidebar,
body.light-theme .sidebar,
body.dark-theme .top-bar,
body.light-theme .top-bar,
body.dark-theme .widget,
body.light-theme .widget,
body.dark-theme .modal-content,
body.light-theme .modal-content,
body.dark-theme .login-box,
body.light-theme .login-box,
body.dark-theme .client-settings-section,
body.light-theme .client-settings-section,
body.dark-theme .oauth-app-card,
body.light-theme .oauth-app-card,
body.dark-theme .client-modal-form-card,
body.light-theme .client-modal-form-card,
body.dark-theme .settings-toolbar,
body.light-theme .settings-toolbar,
body.dark-theme .settings-table-wrap,
body.light-theme .settings-table-wrap,
body.dark-theme .ai-option-card,
body.light-theme .ai-option-card,
body.dark-theme .saved-ai-report-card,
body.light-theme .saved-ai-report-card {
    background: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-soft);
}

body.dark-theme .modal-backdrop,
body.light-theme .modal-backdrop,
body.dark-theme .modal-overlay,
body.light-theme .modal-overlay {
    background: var(--modal-overlay) !important;
}

/* User access dashboard */
.users-access-modal {
    width: min(1180px, calc(100vw - 40px));
    max-width: 1180px;
    max-height: 90vh;
    overflow: hidden;
    padding: 0 !important;
    direction: rtl;
}

.users-access-header,
.users-access-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
}

.users-access-header h2 {
    margin: 6px 0;
    color: var(--text-primary);
    font-size: 24px;
}

.users-access-header h2 i {
    color: var(--accent-blue);
    margin-left: 8px;
}

.users-access-header p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.8;
}

.users-access-close {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.users-access-body {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 18px;
    padding: 22px 28px;
    max-height: calc(90vh - 172px);
    overflow: hidden;
}

.users-access-list-panel,
.users-access-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    min-height: 420px;
    overflow: hidden;
}

.users-access-panel-title,
.users-access-selected-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--border-color);
}

.users-access-panel-title strong,
.users-access-selected-head h3 {
    color: var(--text-primary);
    margin: 0;
}

.users-access-panel-title span {
    min-width: 34px;
    height: 28px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.14);
    color: var(--accent-blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.users-access-title-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.users-add-btn {
    padding: 8px 12px;
    font-size: 13px;
}

.users-create-panel {
    margin: 14px;
    padding: 14px;
    border: 1px solid rgba(59, 130, 246, 0.28);
    border-radius: 16px;
    background: var(--bg-panel);
}

.users-create-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.users-create-grid label,
.users-create-check {
    display: grid;
    gap: 6px;
    color: var(--text-primary);
    font-weight: 800;
}

.users-create-grid label span,
.users-create-check span {
    color: var(--text-secondary);
    font-size: 13px;
}

.users-create-panel .form-control {
    width: 100%;
    min-height: 44px;
    color: var(--text-primary);
    background: var(--bg-dark);
    border-color: var(--border-color);
}

body.light-theme .users-create-panel .form-control {
    background: #fff;
    color: #0f172a;
}

.users-create-check {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    margin: 12px 0;
}

.users-create-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.users-create-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.users-access-selected-head p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.users-access-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.users-access-list,
.users-access-clients {
    padding: 14px;
    overflow-y: auto;
    max-height: calc(90vh - 260px);
}

.users-access-user {
    width: 100%;
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-primary);
    border-radius: 14px;
    padding: 12px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    text-align: right;
    cursor: pointer;
    margin-bottom: 10px;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.users-access-user:hover,
.users-access-user.active {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.12);
}

.users-access-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.users-access-user-main {
    min-width: 0;
}

.users-access-user-main strong,
.users-access-user-main small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.users-access-user-main small {
    color: var(--text-secondary);
    margin-top: 4px;
    direction: ltr;
    text-align: right;
}

.users-access-badge {
    border-radius: 999px;
    padding: 6px 10px;
    background: rgba(16, 185, 129, 0.14);
    color: #10b981;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.users-access-badge.admin {
    background: rgba(139, 92, 246, 0.16);
    color: #8b5cf6;
}

.users-access-clients {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.users-access-client {
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 14px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.users-access-client.checked {
    border-color: rgba(16, 185, 129, 0.65);
    background: rgba(16, 185, 129, 0.10);
}

.users-access-client input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.users-access-client strong,
.users-access-client small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.users-access-client strong {
    color: var(--text-primary);
}

.users-access-client small {
    color: var(--text-secondary);
    margin-top: 4px;
    direction: ltr;
    text-align: right;
}

.users-access-client i {
    color: var(--accent-blue);
}

.users-access-admin-note {
    grid-column: 1 / -1;
    border: 1px solid rgba(139, 92, 246, 0.35);
    background: rgba(139, 92, 246, 0.12);
    border-radius: 18px;
    padding: 22px;
    color: var(--text-primary);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.users-access-admin-note i {
    color: #8b5cf6;
    font-size: 26px;
}

.users-access-admin-note p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    line-height: 1.8;
}

.users-access-footer {
    border-top: 1px solid var(--border-color);
    border-bottom: 0;
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .users-access-body {
        grid-template-columns: 1fr;
        max-height: calc(90vh - 172px);
        overflow-y: auto;
    }
    .users-access-list,
    .users-access-clients {
        max-height: none;
    }
    .users-access-selected-head {
        flex-direction: column;
    }
}

/* Integrated agency report: narrative and charts live in the same story block. */
.agency-integrated-story .agency-section-head {
    margin-bottom: 4px;
}

.agency-integrated-story .agency-story-block {
    overflow: hidden;
}

body.dark-theme .agency-story-block {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.92), rgba(17, 24, 39, 0.95));
    border-color: rgba(148, 163, 184, 0.20);
}

body.dark-theme .agency-story-block.featured {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.22), rgba(88, 28, 135, 0.18)), #151927;
    border-color: rgba(96, 165, 250, 0.32);
}

body.dark-theme .agency-story-visual,
body.dark-theme .agency-story-pill {
    background: rgba(15, 17, 26, 0.78);
    border-color: rgba(148, 163, 184, 0.18);
}

body.light-theme .agency-story-block {
    background: linear-gradient(135deg, #ffffff, #f4f8ff);
    border-color: #cbd5e1;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

body.light-theme .agency-story-block.featured {
    background: linear-gradient(135deg, #eff6ff, #f5f3ff);
    border-color: #bfdbfe;
}

body.light-theme .agency-story-visual,
body.light-theme .agency-story-pill {
    background: #ffffff;
    border-color: #d7e2f0;
}

body.light-theme .agency-story-copy h3,
body.light-theme .agency-story-visual h4,
body.light-theme .agency-story-pill strong {
    color: #0f172a;
}

body.light-theme .agency-story-copy p {
    color: #334155 !important;
}

body.light-theme .agency-story-kicker,
body.light-theme .agency-story-pill b {
    color: #64748b !important;
}

@media (max-width: 1024px) {
    .agency-story-block,
    .agency-story-block.featured {
        grid-template-columns: 1fr;
    }

    .agency-story-visual canvas {
        height: 260px !important;
    }
}

@media (max-width: 640px) {
    .agency-story-block,
    .agency-story-block.featured,
    .agency-story-visual {
        padding: 14px;
    }

    .agency-story-pills {
        display: grid;
        grid-template-columns: 1fr;
    }

    .agency-story-pill {
        min-width: 0;
    }
}

/* Login redesign final theme layer */
body.dark-theme .login-page,
body.light-theme .login-page {
    background:
        linear-gradient(135deg, rgba(59, 130, 246, .13), transparent 34%),
        linear-gradient(315deg, rgba(16, 185, 129, .10), transparent 34%),
        var(--bg-dark) !important;
}

body.dark-theme .login-shell,
body.light-theme .login-shell {
    background: rgba(26, 29, 45, .78) !important;
    border-color: rgba(148, 163, 184, .18) !important;
}

body.dark-theme .login-form-panel,
body.light-theme .login-form-panel {
    background: var(--bg-panel) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .login-visual-panel,
body.light-theme .login-visual-panel {
    background:
        linear-gradient(135deg, rgba(59, 130, 246, .18), rgba(139, 92, 246, .10)),
        #0f111a !important;
}

body.dark-theme .login-visual-head h2,
body.light-theme .login-visual-head h2,
body.dark-theme .visual-kpi-grid strong,
body.light-theme .visual-kpi-grid strong,
body.dark-theme .visual-donut strong,
body.light-theme .visual-donut strong {
    color: #ffffff !important;
}

body.dark-theme .login-visual-head p,
body.light-theme .login-visual-head p,
body.dark-theme .visual-toolbar strong,
body.light-theme .visual-toolbar strong,
body.dark-theme .visual-donut small,
body.light-theme .visual-donut small {
    color: #b7c4d8 !important;
}

body.dark-theme .login-input-wrap .form-control,
body.light-theme .login-input-wrap .form-control {
    height: 56px;
    padding: 14px 46px 14px 50px;
    border-radius: 14px;
    box-shadow: none;
}

body.light-theme .login-shell {
    background: rgba(255, 255, 255, .86) !important;
    box-shadow: 0 34px 90px rgba(15, 23, 42, .14);
}

body.light-theme .login-form-panel {
    background: #ffffff !important;
}

body.light-theme .login-input-wrap .form-control {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

body.light-theme .login-security-note {
    background: #ecfdf5;
    color: #475569;
}

body.light-theme .login-copy p,
body.light-theme .login-brand-row span {
    color: #475569 !important;
}

body.light-theme .login-feature-grid div,
body.light-theme .visual-kpi-grid div,
body.light-theme .visual-report-card {
    background: rgba(15, 23, 42, .42);
}

@media (max-width: 980px) {
    .login-page {
        padding: 20px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .login-shell {
        min-height: auto;
        grid-template-columns: 1fr;
    }

    .login-form-panel {
        order: 1;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
    }

    .login-visual-panel {
        order: 2;
    }

    .login-feature-grid,
    .visual-kpi-grid {
        grid-template-columns: 1fr;
    }

    .visual-chart-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .login-page {
        padding: 12px;
    }

    .login-form-panel,
    .login-visual-panel {
        padding: 24px;
    }

    .login-brand-row {
        margin-bottom: 28px;
    }

    .login-dashboard-visual {
        padding: 14px;
    }
}

/* X report professional insight panels */
.x-report-panel {
    min-height: 360px;
}

.x-summary-grid,
.x-performance-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    direction: rtl;
}

.x-profile-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-dark);
}

.x-profile-avatar {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
    display: grid;
    place-items: center;
    flex: 0 0 54px;
    overflow: hidden;
    font-size: 24px;
}

.x-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.x-profile-row strong,
.x-highlight-number strong,
.x-performance-list strong,
.x-summary-metrics strong {
    color: var(--text-primary);
}

.x-profile-row span,
.x-highlight-number span,
.x-performance-list span,
.x-summary-metrics span,
.x-data-note,
.x-top-post {
    color: var(--text-secondary);
}

.x-profile-row strong {
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
}

.x-summary-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.x-summary-metrics > div,
.x-performance-list > div,
.x-highlight-number,
.x-top-post {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
}

.x-summary-metrics > div {
    padding: 13px;
}

.x-summary-metrics span,
.x-performance-list span,
.x-highlight-number span {
    display: block;
    font-size: 12px;
    line-height: 1.6;
}

.x-summary-metrics strong,
.x-performance-list strong {
    display: block;
    margin-top: 5px;
    font-size: 18px;
    line-height: 1.4;
}

.x-data-note {
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.18);
    line-height: 1.8;
}

.x-highlight-number {
    padding: 16px;
}

.x-highlight-number strong {
    display: block;
    margin-top: 6px;
    font-size: 32px;
    color: var(--accent-green);
}

.x-performance-list {
    display: grid;
    gap: 10px;
}

.x-performance-list > div {
    padding: 12px 14px;
}

.x-top-post {
    margin: 0;
    padding: 13px 14px;
    line-height: 1.9;
}

@media (max-width: 900px) {
    .x-summary-metrics {
        grid-template-columns: 1fr;
    }
}

/* Cross-platform smart performance panels */
.platform-smart-panel {
    min-height: 430px;
}

.smart-insight-panel {
    display: grid;
    gap: 16px;
    direction: rtl;
    min-width: 0;
}

.smart-kpi-strip,
.smart-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.smart-kpi-strip > div,
.smart-detail-grid > div,
.smart-chart-card,
.smart-narrative {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 14px;
}

.smart-kpi-strip > div,
.smart-detail-grid > div {
    padding: 12px 14px;
    min-width: 0;
}

.smart-kpi-strip span,
.smart-detail-grid span,
.smart-chart-card > span {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

.smart-kpi-strip strong,
.smart-detail-grid strong {
    display: block;
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.5;
    margin-top: 4px;
}

.smart-chart-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.smart-chart-card {
    padding: 12px;
    min-height: 190px;
    min-width: 0;
}

.smart-chart-card > span {
    color: var(--text-primary);
    font-weight: 800;
    margin-bottom: 8px;
}

.smart-chart-box {
    height: 145px;
    position: relative;
}

.x-performance-card .smart-kpi-strip,
.x-performance-card .smart-detail-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.x-performance-card .smart-chart-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.x-performance-card .smart-kpi-strip strong,
.x-performance-card .smart-detail-grid strong {
    font-size: 16px;
}

.x-performance-card .smart-chart-card {
    min-height: 170px;
}

.x-performance-card .smart-chart-box {
    height: 125px;
}

.smart-narrative {
    color: var(--text-secondary);
    margin: 0;
    padding: 14px 16px;
    line-height: 1.9;
}

.smart-client-summary {
    display: grid;
    grid-template-columns: 1.15fr repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-width: 0;
}

.smart-client-card {
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
    min-height: 148px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.smart-client-card.primary {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(16, 185, 129, 0.10));
    border-color: rgba(59, 130, 246, 0.32);
}

.smart-client-card span {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.6;
}

.smart-client-card strong {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 900;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.smart-client-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.9;
}

.smart-intel-console {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.10), rgba(139, 92, 246, 0.08));
    border-radius: 16px;
    min-width: 0;
}

.smart-intel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.smart-intel-head span {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
}

.smart-intel-head strong {
    display: block;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
}

.smart-intel-head > i {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.24);
    flex: 0 0 auto;
}

.smart-intel-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.smart-intel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.5;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.smart-intel-btn:hover,
.smart-intel-btn:focus-visible,
.smart-intel-btn.active {
    outline: none;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.smart-intel-output {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.smart-intel-summary {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.smart-intel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.smart-intel-title i {
    color: var(--accent-green);
}

.smart-intel-summary p,
.smart-intel-verdict p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.85;
    font-size: 13px;
}

.smart-intel-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.smart-intel-metrics > div {
    padding: 12px;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    min-width: 0;
}

.smart-intel-metrics span {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.smart-intel-metrics strong {
    display: block;
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.35;
    margin: 4px 0;
    overflow-wrap: anywhere;
}

.smart-intel-metrics small {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.65;
}

.smart-intel-verdict {
    display: grid;
    gap: 8px;
    padding: 13px 15px;
    border-radius: 14px;
    background: rgba(16, 185, 129, 0.10);
    border: 1px solid rgba(16, 185, 129, 0.24);
}

.smart-intel-verdict strong {
    display: block;
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 13px;
}

body.light-theme .smart-intel-console {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.07));
}

body.light-theme .smart-intel-verdict {
    background: rgba(5, 150, 105, 0.08);
    border-color: rgba(5, 150, 105, 0.22);
}

body.light-theme .smart-client-card {
    background: #ffffff;
    border-color: #d7e2f0;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

body.light-theme .smart-client-card.primary {
    background: linear-gradient(135deg, #eff6ff, #ecfdf5);
    border-color: #b7d3ff;
}

.smart-click-card {
    cursor: pointer;
    position: relative;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.smart-click-card::after {
    content: "\f35d";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 10px;
    left: 10px;
    color: var(--accent-blue);
    font-size: 11px;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.smart-click-card:hover,
.smart-click-card:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.55);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-soft);
    outline: none;
}

.smart-click-card:hover::after,
.smart-click-card:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

.smart-modal-content {
    width: min(1120px, calc(100vw - 32px));
    max-width: 1120px;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 26px;
    direction: rtl;
}

.smart-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
}

.smart-modal-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.14);
    border: 1px solid rgba(59, 130, 246, 0.24);
    font-size: 22px;
}

#smartModalEyebrow {
    margin: 0 0 6px;
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0;
}

#smartModalTitle {
    margin: 0;
    color: var(--text-primary);
    font-size: 26px;
    line-height: 1.35;
}

.smart-modal-body {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.smart-modal-hero,
.smart-modal-chart-card,
.smart-modal-analysis-card,
.smart-modal-actions-card,
.smart-modal-related-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.smart-modal-hero {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 18px;
    align-items: center;
    padding: 18px;
}

.smart-modal-hero span,
.smart-modal-related-item span {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.7;
}

.smart-modal-hero strong {
    display: block;
    color: var(--text-primary);
    font-size: 34px;
    line-height: 1.2;
    margin-top: 4px;
}

.smart-modal-hero p,
.smart-modal-analysis-card p,
.smart-modal-actions-card li {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.9;
    font-size: 15px;
}

.smart-modal-split {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: 16px;
    min-width: 0;
}

.smart-modal-chart-card,
.smart-modal-analysis-card,
.smart-modal-actions-card {
    padding: 18px;
    min-width: 0;
}

.smart-modal-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 800;
    margin-bottom: 14px;
}

.smart-modal-section-title i {
    color: var(--accent-purple);
}

.smart-modal-chart-box {
    height: 280px;
    position: relative;
}

.smart-modal-related-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.smart-modal-related-item {
    padding: 14px;
    min-width: 0;
}

.smart-modal-related-item strong {
    display: block;
    color: var(--text-primary);
    font-size: 20px;
    line-height: 1.4;
    margin: 4px 0;
    overflow-wrap: anywhere;
}

.smart-modal-related-item small {
    display: block;
    color: var(--text-muted);
    line-height: 1.7;
}

.smart-modal-actions-card ul {
    margin: 0;
    padding: 0 20px 0 0;
}

.smart-modal-actions-card li + li {
    margin-top: 8px;
}

body.light-theme .smart-modal-icon,
body.light-theme .smart-click-card::after {
    color: #2563eb;
}

body.light-theme .smart-click-card:hover,
body.light-theme .smart-click-card:focus-visible {
    border-color: rgba(37, 99, 235, 0.45);
}

@media (max-width: 1100px) {
    .smart-kpi-strip,
    .smart-client-summary,
    .smart-detail-grid,
    .smart-chart-grid,
    .smart-intel-tabs,
    .smart-intel-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1300px) {
    .x-performance-card .smart-kpi-strip,
    .x-performance-card .smart-detail-grid,
    .x-performance-card .smart-chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .smart-kpi-strip,
    .smart-client-summary,
    .smart-detail-grid,
    .smart-chart-grid,
    .smart-intel-tabs,
    .smart-intel-metrics {
        grid-template-columns: 1fr;
    }

    .smart-modal-content {
        width: calc(100vw - 20px);
        padding: 20px 16px;
    }

    .smart-modal-header,
    .smart-modal-hero,
    .smart-modal-split,
    .smart-modal-related-grid {
        grid-template-columns: 1fr;
    }

    .smart-modal-hero strong {
        font-size: 28px;
    }

    .smart-modal-chart-box {
        height: 240px;
    }
}

/* Root theme contract: this final layer owns readability across pages, modals, reports, and exports. */
body.dark-theme {
    --bg-dark: #0f111a;
    --bg-panel: #1a1d2d;
    --bg-panel-hover: #24283b;
    --bg-card: #171b2b;
    --bg-elevated: #202437;
    --text-primary: #f8fafc;
    --text-secondary: #b7c4d8;
    --text-muted: #8ea0b8;
    --border-color: #313850;
    --input-bg: #0f1320;
    --input-text: #f8fafc;
    --empty-bg: rgba(59, 130, 246, 0.09);
    --empty-border: rgba(96, 165, 250, 0.24);
    --modal-overlay: rgba(5, 8, 18, 0.78);
    --chart-label: #f8fafc;
    --chart-muted: #b7c4d8;
    --chart-grid: rgba(148, 163, 184, 0.18);
    --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.35);
}

body.light-theme {
    --bg-dark: #eef3f8;
    --bg-panel: #ffffff;
    --bg-panel-hover: #f3f7fb;
    --bg-card: #f8fbff;
    --bg-elevated: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #d7e0ea;
    --input-bg: #ffffff;
    --input-text: #0f172a;
    --empty-bg: #f1f7ff;
    --empty-border: #bfdbfe;
    --modal-overlay: rgba(15, 23, 42, 0.52);
    --chart-label: #0f172a;
    --chart-muted: #475569;
    --chart-grid: rgba(71, 85, 105, 0.26);
    --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body.dark-theme,
body.light-theme,
body.dark-theme .main-content,
body.light-theme .main-content,
body.dark-theme .login-page,
body.light-theme .login-page {
    background: var(--bg-dark) !important;
    color: var(--text-primary) !important;
}

body.dark-theme .sidebar,
body.light-theme .sidebar,
body.dark-theme .top-bar,
body.light-theme .top-bar,
body.dark-theme .widget,
body.light-theme .widget,
body.dark-theme .modal-content,
body.light-theme .modal-content,
body.dark-theme .client-settings-modal,
body.light-theme .client-settings-modal,
body.dark-theme .oauth-apps-modal,
body.light-theme .oauth-apps-modal,
body.dark-theme .client-settings-section,
body.light-theme .client-settings-section,
body.dark-theme .oauth-app-card,
body.light-theme .oauth-app-card,
body.dark-theme .client-modal-form-card,
body.light-theme .client-modal-form-card,
body.dark-theme .settings-toolbar,
body.light-theme .settings-toolbar,
body.dark-theme .settings-table-wrap,
body.light-theme .settings-table-wrap,
body.dark-theme .ai-report-center-modal,
body.light-theme .ai-report-center-modal,
body.dark-theme .ai-report-center-panel,
body.light-theme .ai-report-center-panel,
body.dark-theme .ai-option-card,
body.light-theme .ai-option-card,
body.dark-theme .saved-ai-report-card,
body.light-theme .saved-ai-report-card,
body.dark-theme .ai-report-card,
body.light-theme .ai-report-card,
body.dark-theme .agency-section,
body.light-theme .agency-section,
body.dark-theme .agency-cover aside,
body.light-theme .agency-cover aside,
body.dark-theme .agency-chart-card,
body.light-theme .agency-chart-card,
body.dark-theme .agency-table-card,
body.light-theme .agency-table-card,
body.dark-theme .agency-ai-block,
body.light-theme .agency-ai-block,
body.dark-theme .agency-insight-card,
body.light-theme .agency-insight-card,
body.dark-theme .agency-observation-card,
body.light-theme .agency-observation-card,
body.dark-theme .agency-platform-summary,
body.light-theme .agency-platform-summary,
body.dark-theme .agency-platform-proof,
body.light-theme .agency-platform-proof {
    background: var(--bg-panel) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-soft);
}

body.dark-theme .client-settings-section,
body.light-theme .client-settings-section,
body.dark-theme .ai-report-center-panel,
body.light-theme .ai-report-center-panel,
body.dark-theme .client-modal-form-card,
body.light-theme .client-modal-form-card,
body.dark-theme .platform-connect-row.not-configured,
body.light-theme .platform-connect-row.not-configured {
    background: var(--bg-card) !important;
}

body.dark-theme h1,
body.light-theme h1,
body.dark-theme h2,
body.light-theme h2,
body.dark-theme h3,
body.light-theme h3,
body.dark-theme h4,
body.light-theme h4,
body.dark-theme .brand,
body.light-theme .brand,
body.dark-theme .widget-value,
body.light-theme .widget-value,
body.dark-theme .ai-report-title,
body.light-theme .ai-report-title,
body.dark-theme .ai-report-center-head h2,
body.light-theme .ai-report-center-head h2,
body.dark-theme .client-settings-head h2,
body.light-theme .client-settings-head h2,
body.dark-theme .saved-ai-report-card strong,
body.light-theme .saved-ai-report-card strong,
body.dark-theme .agency-kpi strong,
body.light-theme .agency-kpi strong,
body.dark-theme .agency-platform-kpi strong,
body.light-theme .agency-platform-kpi strong {
    color: var(--text-primary) !important;
}

body.dark-theme p,
body.light-theme p,
body.dark-theme small,
body.light-theme small,
body.dark-theme .widget-title,
body.light-theme .widget-title,
body.dark-theme .page-titles p,
body.light-theme .page-titles p,
body.dark-theme .ai-report-subtitle,
body.light-theme .ai-report-subtitle,
body.dark-theme .client-settings-head p,
body.light-theme .client-settings-head p,
body.dark-theme .client-modal-field-note,
body.light-theme .client-modal-field-note,
body.dark-theme .ai-field-label,
body.light-theme .ai-field-label,
body.dark-theme .platform-connect-row span,
body.light-theme .platform-connect-row span,
body.dark-theme .platform-connect-row small,
body.light-theme .platform-connect-row small,
body.dark-theme .agency-chart-note,
body.light-theme .agency-chart-note,
body.dark-theme .agency-section-head span,
body.light-theme .agency-section-head span {
    color: var(--text-secondary) !important;
}

body.dark-theme .form-control,
body.light-theme .form-control,
body.dark-theme .control-select,
body.light-theme .control-select,
body.dark-theme input,
body.light-theme input,
body.dark-theme select,
body.light-theme select,
body.dark-theme textarea,
body.light-theme textarea {
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
    border-color: var(--border-color) !important;
    -webkit-text-fill-color: var(--input-text) !important;
}

body.dark-theme .form-control::placeholder,
body.light-theme .form-control::placeholder,
body.dark-theme input::placeholder,
body.light-theme input::placeholder,
body.dark-theme textarea::placeholder,
body.light-theme textarea::placeholder {
    color: var(--text-muted) !important;
    opacity: 1 !important;
    -webkit-text-fill-color: var(--text-muted) !important;
}

body.dark-theme .form-control:disabled,
body.light-theme .form-control:disabled,
body.dark-theme .form-control[readonly],
body.light-theme .form-control[readonly],
body.dark-theme input:disabled,
body.light-theme input:disabled {
    background: var(--bg-panel-hover) !important;
    color: var(--text-secondary) !important;
    -webkit-text-fill-color: var(--text-secondary) !important;
}

body.dark-theme .data-table th,
body.light-theme .data-table th,
body.dark-theme .settings-clients-table th,
body.light-theme .settings-clients-table th,
body.dark-theme .markdown-body th,
body.light-theme .markdown-body th,
body.dark-theme .agency-data-table th,
body.light-theme .agency-data-table th {
    background: var(--bg-panel-hover) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .data-table td,
body.light-theme .data-table td,
body.dark-theme .settings-clients-table td,
body.light-theme .settings-clients-table td,
body.dark-theme .markdown-body td,
body.light-theme .markdown-body td,
body.dark-theme .agency-data-table td,
body.light-theme .agency-data-table td {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .theme-empty-state,
body.light-theme .theme-empty-state,
body.dark-theme .chart-empty-state,
body.light-theme .chart-empty-state,
body.dark-theme [id$="-empty"],
body.light-theme [id$="-empty"],
body.dark-theme .agency-chart-empty-state,
body.light-theme .agency-chart-empty-state,
body.dark-theme .agency-empty,
body.light-theme .agency-empty,
body.dark-theme .settings-empty-state,
body.light-theme .settings-empty-state,
body.dark-theme .ai-report-list-empty,
body.light-theme .ai-report-list-empty {
    background: var(--empty-bg) !important;
    border: 1px dashed var(--empty-border) !important;
    color: var(--text-secondary) !important;
    opacity: 1 !important;
}

body.dark-theme .modal-backdrop,
body.light-theme .modal-backdrop,
body.dark-theme .modal-overlay,
body.light-theme .modal-overlay,
body.dark-theme .client-settings-backdrop,
body.light-theme .client-settings-backdrop,
body.dark-theme .ai-report-center-backdrop,
body.light-theme .ai-report-center-backdrop {
    background: var(--modal-overlay) !important;
}

body.dark-theme .modal-close,
body.light-theme .modal-close,
body.dark-theme .icon-action-btn,
body.light-theme .icon-action-btn,
body.dark-theme .settings-switch,
body.light-theme .settings-switch,
body.dark-theme .btn-outline,
body.light-theme .btn-outline {
    background: var(--bg-panel-hover) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme canvas,
body.light-theme canvas {
    color: var(--chart-label);
}

body.dark-theme .brand,
body.light-theme .brand,
body.dark-theme .page-titles h1,
body.light-theme .page-titles h1,
body.dark-theme .widget-value,
body.light-theme .widget-value,
body.dark-theme .modal-content h1,
body.light-theme .modal-content h1,
body.dark-theme .modal-content h2,
body.light-theme .modal-content h2,
body.dark-theme .modal-content h3,
body.light-theme .modal-content h3,
body.dark-theme .client-settings-head h2,
body.light-theme .client-settings-head h2,
body.dark-theme .client-settings-section h3,
body.light-theme .client-settings-section h3,
body.dark-theme .oauth-app-card-head h3,
body.light-theme .oauth-app-card-head h3,
body.dark-theme .ai-report-title,
body.light-theme .ai-report-title,
body.dark-theme .saved-ai-report-card strong,
body.light-theme .saved-ai-report-card strong,
body.dark-theme .ai-option-card strong,
body.light-theme .ai-option-card strong {
    color: var(--text-primary) !important;
}

body.dark-theme .page-titles p,
body.light-theme .page-titles p,
body.dark-theme .widget-title,
body.light-theme .widget-title,
body.dark-theme .form-group label,
body.light-theme .form-group label,
body.dark-theme .client-settings-head p,
body.light-theme .client-settings-head p,
body.dark-theme .platform-connect-row span,
body.light-theme .platform-connect-row span,
body.dark-theme .client-modal-field-note,
body.light-theme .client-modal-field-note,
body.dark-theme .settings-empty-state,
body.light-theme .settings-empty-state,
body.dark-theme .ai-report-subtitle,
body.light-theme .ai-report-subtitle,
body.dark-theme .ai-report-list-empty,
body.light-theme .ai-report-list-empty,
body.dark-theme .saved-ai-report-card small,
body.light-theme .saved-ai-report-card small {
    color: var(--text-secondary) !important;
}

body.dark-theme .nav-item,
body.light-theme .nav-item {
    color: var(--text-secondary) !important;
}

body.dark-theme .nav-item:hover,
body.light-theme .nav-item:hover {
    background: var(--bg-panel-hover) !important;
    color: var(--text-primary) !important;
}

body.dark-theme .nav-item.active,
body.light-theme .nav-item.active {
    background: rgba(59, 130, 246, 0.15) !important;
    color: var(--accent-blue) !important;
    border-color: var(--accent-blue) !important;
}

body.dark-theme .form-control,
body.light-theme .form-control,
body.dark-theme .control-select,
body.light-theme .control-select,
body.dark-theme input,
body.light-theme input,
body.dark-theme select,
body.light-theme select,
body.dark-theme textarea,
body.light-theme textarea {
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
    border-color: var(--border-color) !important;
    -webkit-text-fill-color: var(--input-text);
}

body.dark-theme .form-control::placeholder,
body.light-theme .form-control::placeholder,
body.dark-theme input::placeholder,
body.light-theme input::placeholder,
body.dark-theme textarea::placeholder,
body.light-theme textarea::placeholder {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

body.dark-theme .form-control:disabled,
body.light-theme .form-control:disabled,
body.dark-theme .form-control[readonly],
body.light-theme .form-control[readonly] {
    background: var(--bg-panel-hover) !important;
    color: var(--text-secondary) !important;
    -webkit-text-fill-color: var(--text-secondary);
}

body.dark-theme .btn-outline,
body.light-theme .btn-outline,
body.dark-theme .icon-action-btn,
body.light-theme .icon-action-btn,
body.dark-theme .settings-switch,
body.light-theme .settings-switch {
    background: transparent !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .btn-outline:hover,
body.light-theme .btn-outline:hover,
body.dark-theme .icon-action-btn:hover,
body.light-theme .icon-action-btn:hover {
    background: var(--bg-panel-hover) !important;
    border-color: rgba(59, 130, 246, 0.45) !important;
}

body.dark-theme .data-table th,
body.light-theme .data-table th,
body.dark-theme .markdown-body th,
body.light-theme .markdown-body th,
body.dark-theme .agency-data-table th,
body.light-theme .agency-data-table th {
    background: var(--bg-panel-hover) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .data-table td,
body.light-theme .data-table td,
body.dark-theme .markdown-body td,
body.light-theme .markdown-body td,
body.dark-theme .agency-data-table td,
body.light-theme .agency-data-table td {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .data-table tr:hover td,
body.light-theme .data-table tr:hover td,
body.dark-theme .markdown-body tr:nth-child(even) td,
body.light-theme .markdown-body tr:nth-child(even) td {
    background: var(--row-hover) !important;
}

body.dark-theme .theme-empty-state,
body.light-theme .theme-empty-state,
body.dark-theme .chart-empty-state,
body.light-theme .chart-empty-state,
body.dark-theme [id$="-empty"],
body.light-theme [id$="-empty"],
body.dark-theme .agency-chart-empty-state,
body.light-theme .agency-chart-empty-state,
body.dark-theme .agency-empty,
body.light-theme .agency-empty,
body.dark-theme .ai-report-list-empty,
body.light-theme .ai-report-list-empty {
    background: var(--empty-bg) !important;
    border: 1px dashed var(--empty-border) !important;
    color: var(--text-secondary) !important;
    border-radius: 12px !important;
}

body.dark-theme .theme-empty-state,
body.light-theme .theme-empty-state,
body.dark-theme .chart-empty-state,
body.light-theme .chart-empty-state {
    min-height: 150px;
}

body.dark-theme .agency-chart-empty-state i,
body.light-theme .agency-chart-empty-state i,
body.dark-theme .theme-empty-state i,
body.light-theme .theme-empty-state i {
    color: var(--accent-blue) !important;
}

body.dark-theme .modal-close,
body.light-theme .modal-close {
    background: var(--bg-panel-hover) !important;
    color: var(--text-secondary) !important;
}

body.dark-theme .modal-close:hover,
body.light-theme .modal-close:hover {
    background: rgba(239, 68, 68, 0.16) !important;
    color: var(--danger) !important;
}

body.dark-theme #widget-modal-summary,
body.light-theme #widget-modal-summary,
body.dark-theme #modal-smart-summary,
body.light-theme #modal-smart-summary {
    color: var(--text-primary) !important;
}

body.dark-theme #modal-stat-views,
body.light-theme #modal-stat-views,
body.dark-theme #modal-stat-reach,
body.light-theme #modal-stat-reach,
body.dark-theme #modal-stat-eng,
body.light-theme #modal-stat-eng,
body.dark-theme #modal-stat-follows,
body.light-theme #modal-stat-follows,
body.dark-theme #modal-chart-views-val,
body.light-theme #modal-chart-views-val,
body.dark-theme #modal-stat-likes,
body.light-theme #modal-stat-likes,
body.dark-theme #modal-stat-comments,
body.light-theme #modal-stat-comments,
body.dark-theme #modal-stat-shares,
body.light-theme #modal-stat-shares,
body.dark-theme #modal-stat-saves,
body.light-theme #modal-stat-saves {
    color: var(--text-primary) !important;
}

body.dark-theme .platform-connect-row,
body.light-theme .platform-connect-row {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08)) !important;
    border-color: rgba(59, 130, 246, 0.24) !important;
}

body.dark-theme .platform-connect-row.not-configured,
body.light-theme .platform-connect-row.not-configured {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}


/* Light Theme */
.light-theme {
    --bg-dark: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-panel-hover: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
}
.light-theme .brand { color: #1e293b; }
.light-theme .nav-item:hover { color: #1e293b; }
.light-theme .widget-value { color: #1e293b; }
.light-theme .widget-trend.positive { color: #10b981; }
.light-theme .widget-trend.negative { color: #ef4444; }
.light-theme .table th { background: #f8fafc; color: #475569; }
.light-theme .table td { border-bottom-color: #e2e8f0; }
.light-theme .control-select { background: #ffffff; color: #1e293b; border-color: #cbd5e1; }
.light-theme .form-group label,
.light-theme .client-settings-section label,
.light-theme .oauth-app-card label {
    color: #475569;
}
.light-theme .form-control {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
    caret-color: #2563eb;
}
.light-theme .form-control:focus {
    background: #ffffff;
    color: #0f172a;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.light-theme .form-control::placeholder {
    color: #64748b;
    opacity: 1;
}
.light-theme .form-control[readonly],
.light-theme .form-control:disabled {
    background: #eef2f7;
    color: #334155;
    border-color: #dbe4ef;
    -webkit-text-fill-color: #334155;
    opacity: 1;
}
.light-theme .form-control[readonly]::placeholder,
.light-theme .form-control:disabled::placeholder {
    color: #64748b;
    opacity: 1;
}
.light-theme input[type="password"].form-control {
    color: #0f172a;
    -webkit-text-fill-color: #0f172a;
}
.light-theme .btn-outline { color: #1e293b; border-color: #cbd5e1; }
.light-theme .btn-outline:hover { background: #f1f5f9; }
.light-theme .modal-content { background: #ffffff; border-color: #e2e8f0; }
.light-theme .modal-close { color: #64748b; background: #f1f5f9; }
.light-theme .modal-close:hover { background: #fee2e2; color: #ef4444; }
.light-theme .user-profile button:hover { color: var(--accent-blue) !important; }

.light-theme .agency-report {
    color: #0f172a;
}

.light-theme .agency-cover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08)), #ffffff;
    border-color: #bfdbfe;
}

.light-theme .agency-cover aside,
.light-theme .agency-chart-card,
.light-theme .agency-ai-block,
.light-theme .agency-post-card,
.light-theme .agency-table-card,
.light-theme .agency-insight-card,
.light-theme .agency-observation-card,
.light-theme .agency-platform-summary,
.light-theme .agency-platform-proof,
.light-theme .agency-smart-platform {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.light-theme .agency-smart-mode-card {
    background: #ffffff;
    border-color: #cbd5e1;
}

.light-theme .agency-smart-row {
    background: #eef6ff;
    border-color: #bfdbfe;
}

.light-theme .agency-smart-verdict {
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.light-theme .agency-section {
    background: #ffffff;
    border-color: #dbe3ef;
}

.light-theme .agency-cover h1,
.light-theme .agency-cover aside strong,
.light-theme .agency-section-head h2,
.light-theme .agency-chart-card h3,
.light-theme .agency-ai-block h3,
.light-theme .agency-table-card h3,
.light-theme .agency-insight-card strong,
.light-theme .agency-observation-card h3,
.light-theme .agency-markdown h3,
.light-theme .agency-markdown h4,
.light-theme .agency-post-body b,
.light-theme .agency-ai-block strong,
.light-theme .agency-platform-kpi strong,
.light-theme .agency-platform-proof h3,
.light-theme .agency-platform-table h3,
.light-theme .agency-final-recommendation h3,
.light-theme .agency-mini-post strong,
.light-theme .agency-smart-mode-title h4,
.light-theme .agency-smart-row strong,
.light-theme .agency-smart-platform-head span,
.light-theme .agency-smart-verdict strong {
    color: #0f172a;
}

.light-theme .agency-cover p,
.light-theme .agency-cover aside span,
.light-theme .agency-eyebrow,
.light-theme .agency-section-head span,
.light-theme .agency-chart-note,
.light-theme .agency-post-body div,
.light-theme .agency-insight-card span,
.light-theme .agency-chart-empty-state,
.light-theme .agency-mini-post p,
.light-theme .agency-mini-post small,
.light-theme .agency-platform-kpi span,
.light-theme .agency-smart-platform-head strong,
.light-theme .agency-smart-row span,
.light-theme .agency-smart-row small {
    color: #475569;
}

.light-theme .agency-ai-block p,
.light-theme .agency-insight-card p,
.light-theme .agency-observation-card p,
.light-theme .agency-post-body p,
.light-theme .agency-data-table td,
.light-theme .agency-markdown p,
.light-theme .agency-markdown li,
.light-theme .agency-platform-summary p,
.light-theme .agency-final-recommendation p {
    color: #1e293b;
}

.light-theme .agency-smart-mode-card p {
    color: #334155;
}

.light-theme .agency-smart-verdict span {
    color: #047857;
}

.light-theme .agency-kpi {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.light-theme .agency-kpi span {
    color: #475569;
}

.light-theme .agency-kpi strong {
    color: #0f172a;
}

.light-theme .agency-data-table th,
.light-theme .agency-markdown th {
    background: #dbeafe;
    color: #0f172a;
}

.light-theme .agency-data-table th,
.light-theme .agency-data-table td,
.light-theme .agency-markdown th,
.light-theme .agency-markdown td {
    border-color: #cbd5e1;
}

.light-theme .agency-chart-empty-state {
    background: #eef6ff;
    border-color: #bfdbfe;
}


/* ═══════════ v3.0.0 Audit Fixes ═══════════ */

/* Toast Animation */
@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Skeleton Loading */
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--bg-dark) 25%, var(--bg-panel-hover) 50%, var(--bg-dark) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
.skeleton-text { height: 20px; margin-bottom: 10px; }
.skeleton-value { height: 36px; width: 120px; margin-bottom: 10px; }
.skeleton-chart { height: 80px; }

/* Mobile Hamburger */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .sidebar.sidebar-open {
        transform: translateX(0) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
    }
    .sidebar {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Table row click feedback */
.table-row-clickable:active td {
    background: rgba(59, 130, 246, 0.2) !important;
    transition: background 0.1s;
}

/* Widget cursor for clickable widgets */
.widget[onclick] { cursor: pointer; }

/* Load more button enhancement */
#fb-load-more, #ig-load-more {
    padding: 10px 30px;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.3s;
}
#fb-load-more:hover, #ig-load-more:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Smooth widget hover */
.widget {
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.widget:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* ═══════════ AI Report Feature Styles ═══════════ */
.btn-ai {
    background: linear-gradient(135deg, #a855f7, #6366f1, #3b82f6);
    background-size: 200% auto;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    transition: all 0.3s ease;
}
.btn-ai:hover {
    background-position: right center;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}
.btn-ai i {
    animation: pulse-glow 2s infinite alternate;
}

@keyframes pulse-glow {
    0% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(255,255,255,0.6)); }
    100% { transform: scale(1.15); filter: drop-shadow(0 0 6px rgba(255,255,255,0.9)); }
}

.ai-report-card {
    background: rgba(26, 29, 45, 0.7) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.2) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    position: relative;
    overflow: hidden;
}
.ai-report-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #a855f7, #6366f1, #10b981);
}

.ai-report-center-backdrop {
    z-index: 10001;
}

.ai-report-center-modal {
    max-width: 1120px;
    padding: 26px;
}

.ai-report-center-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 20px;
    padding-left: 44px;
}

.ai-report-center-head h2 {
    margin: 0 0 6px;
    color: #fff;
    font-size: 24px;
}

.ai-report-center-head p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.ai-report-center-head > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.28);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.ai-report-center-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
    gap: 16px;
}

.ai-report-center-panel {
    padding: 18px;
    border-radius: 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
}

.ai-report-center-panel h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    color: var(--text-primary);
    font-size: 17px;
}

.ai-field-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 13px;
}

.ai-reports-saved-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    max-height: 420px;
    overflow-y: auto;
    padding-left: 4px;
}

.saved-ai-report-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    background: var(--bg-panel);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.saved-ai-report-card strong,
.saved-ai-report-card span,
.saved-ai-report-card small {
    display: block;
}

.saved-ai-report-card strong {
    color: #fff;
    font-size: 14px;
    margin-bottom: 4px;
}

.saved-ai-report-card span {
    color: #bfdbfe;
    font-size: 13px;
    margin-bottom: 2px;
}

.saved-ai-report-card small {
    color: var(--text-secondary);
    font-size: 12px;
}

.saved-ai-report-card .btn-outline {
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
}

.ai-report-list-empty,
.ai-report-list-loading {
    padding: 22px;
    text-align: center;
    border-radius: 8px;
    color: var(--text-secondary);
    background: rgba(148, 163, 184, 0.08);
    border: 1px dashed rgba(148, 163, 184, 0.22);
}

.ai-generation-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.ai-option-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg-panel);
    border: 1px solid rgba(148, 163, 184, 0.16);
    transition: border-color .2s, background .2s;
}

.ai-option-card:hover {
    border-color: rgba(59, 130, 246, 0.42);
}

.ai-option-card input {
    margin-top: 4px;
    accent-color: var(--accent-blue);
}

.ai-option-card strong {
    display: block;
    color: #fff;
    margin-bottom: 4px;
}

.ai-option-card small {
    color: var(--text-secondary);
    line-height: 1.6;
}

.ai-report-period-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.18);
}

.ai-report-period-box strong {
    color: #fff;
    text-align: left;
}

.ai-generate-final-btn {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.ai-report-cost-note {
    margin: 12px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.7;
}

.light-theme .ai-report-center-head h2,
.light-theme .ai-report-center-panel h3,
.light-theme .saved-ai-report-card strong,
.light-theme .ai-option-card strong,
.light-theme .ai-report-period-box strong {
    color: #1e293b;
}

.light-theme .ai-report-center-panel,
.light-theme .saved-ai-report-card,
.light-theme .ai-option-card {
    background: #f8fafc;
}

@media (max-width: 900px) {
    .ai-report-center-head,
    .ai-report-center-grid {
        grid-template-columns: 1fr;
    }
    .ai-report-center-head {
        flex-direction: column;
    }
    .ai-report-center-modal {
        width: 94%;
        padding: 22px 16px;
    }
    .saved-ai-report-card {
        align-items: stretch;
        flex-direction: column;
    }
    .saved-ai-report-card .btn-outline {
        justify-content: center;
    }
}

.ai-icon-pulse i {
    animation: rotate-sparkle 3s infinite linear;
}
@keyframes rotate-sparkle {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* AI Markdown Rendering Styling */
.markdown-body h3 {
    font-size: 17px;
    font-weight: 700;
    color: #f1f5f9;
    margin-top: 25px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}
.markdown-body h3::before {
    content: '✦';
    color: var(--accent-purple);
}
.markdown-body h4 {
    font-size: 15px;
    font-weight: 600;
    color: #e2e8f0;
    margin-top: 20px;
    margin-bottom: 8px;
}
.markdown-body p {
    margin-bottom: 15px;
    color: #cbd5e1;
    line-height: 1.8;
}
.markdown-body ul, .markdown-body ol {
    margin-bottom: 20px;
    padding-right: 20px;
}
.markdown-body li {
    margin-bottom: 8px;
    color: #cbd5e1;
}
.markdown-body li strong {
    color: #fff;
}
.markdown-body blockquote {
    border-right: 4px solid var(--accent-purple);
    background: rgba(139, 92, 246, 0.08);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 4px 8px 8px 4px;
    color: #e2e8f0;
}
.markdown-body blockquote p {
    margin-bottom: 0;
}
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}
.markdown-body th {
    background: rgba(139, 92, 246, 0.1);
    color: #fff;
    padding: 10px 12px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}
.markdown-body td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    color: #cbd5e1;
}
.markdown-body tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.01);
}
.markdown-body strong {
    color: var(--accent-blue);
    font-weight: 700;
}

/* Light Theme overrides for AI section */
.light-theme .ai-report-card {
    background: rgba(255, 255, 255, 0.8) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255,255,255,0.8);
}
.light-theme .ai-report-title {
    color: #1e293b !important;
}
.light-theme .markdown-body h3 {
    color: #1e293b;
    border-bottom-color: rgba(0, 0, 0, 0.05);
}
.light-theme .markdown-body h4 {
    color: #334155;
}
.light-theme .markdown-body p, .light-theme .markdown-body li {
    color: #475569;
}
.light-theme .markdown-body li strong {
    color: #1e293b;
}
.light-theme .markdown-body blockquote {
    background: rgba(139, 92, 246, 0.05);
    color: #334155;
}
.light-theme .markdown-body th {
    background: rgba(139, 92, 246, 0.05);
    color: #1e293b;
}
.light-theme .markdown-body td {
    color: #475569;
}
.light-theme .markdown-body strong {
    color: #4f46e5;
}

/* Print Styling adjustments */
@media print {
    .ai-report-section {
        display: block !important;
        margin-top: 30px;
        break-inside: avoid;
    }
    .ai-report-card {
        background: #fff !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        color: #000 !important;
    }
    .ai-report-header button {
        display: none !important;
    }
    .markdown-body h3, .markdown-body h4, .markdown-body p, .markdown-body li, .markdown-body td, .markdown-body th {
        color: #000 !important;
    }
    .markdown-body blockquote {
        background: #f9f9f9 !important;
        border-right-color: #333 !important;
    }
}

/* Final theme enforcement: keep the last cascade layer theme-driven */
body.dark-theme,
body.light-theme {
    background: var(--bg-dark) !important;
    color: var(--text-primary) !important;
}

body.dark-theme .sidebar,
body.light-theme .sidebar,
body.dark-theme .main-content,
body.light-theme .main-content,
body.dark-theme .top-bar,
body.light-theme .top-bar,
body.dark-theme .widget,
body.light-theme .widget,
body.dark-theme .modal-content,
body.light-theme .modal-content,
body.dark-theme .client-settings-section,
body.light-theme .client-settings-section,
body.dark-theme .oauth-app-card,
body.light-theme .oauth-app-card,
body.dark-theme .client-modal-form-card,
body.light-theme .client-modal-form-card,
body.dark-theme .ai-report-card,
body.light-theme .ai-report-card,
body.dark-theme .agency-section,
body.light-theme .agency-section {
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .main-content,
body.light-theme .main-content {
    background: var(--bg-dark) !important;
}

body.dark-theme .sidebar,
body.light-theme .sidebar,
body.dark-theme .top-bar,
body.light-theme .top-bar,
body.dark-theme .widget,
body.light-theme .widget,
body.dark-theme .modal-content,
body.light-theme .modal-content,
body.dark-theme .ai-report-card,
body.light-theme .ai-report-card {
    background: var(--bg-panel) !important;
}

body.dark-theme h1,
body.light-theme h1,
body.dark-theme h2,
body.light-theme h2,
body.dark-theme h3,
body.light-theme h3,
body.dark-theme h4,
body.light-theme h4,
body.dark-theme .widget-value,
body.light-theme .widget-value,
body.dark-theme .brand,
body.light-theme .brand,
body.dark-theme .ai-report-title,
body.light-theme .ai-report-title {
    color: var(--text-primary) !important;
}

body.dark-theme p,
body.light-theme p,
body.dark-theme small,
body.light-theme small,
body.dark-theme .widget-title,
body.light-theme .widget-title,
body.dark-theme .page-titles p,
body.light-theme .page-titles p,
body.dark-theme .ai-report-subtitle,
body.light-theme .ai-report-subtitle,
body.dark-theme .client-modal-field-note,
body.light-theme .client-modal-field-note {
    color: var(--text-secondary) !important;
}

body.dark-theme .theme-empty-state,
body.light-theme .theme-empty-state,
body.dark-theme .chart-empty-state,
body.light-theme .chart-empty-state,
body.dark-theme [id$="-empty"],
body.light-theme [id$="-empty"],
body.dark-theme .agency-chart-empty-state,
body.light-theme .agency-chart-empty-state,
body.dark-theme .agency-empty,
body.light-theme .agency-empty,
body.dark-theme .settings-empty-state,
body.light-theme .settings-empty-state,
body.dark-theme .ai-report-list-empty,
body.light-theme .ai-report-list-empty {
    background: var(--empty-bg) !important;
    border: 1px dashed var(--empty-border) !important;
    color: var(--text-secondary) !important;
    opacity: 1 !important;
}

body.dark-theme .form-control,
body.light-theme .form-control,
body.dark-theme .control-select,
body.light-theme .control-select,
body.dark-theme input,
body.light-theme input,
body.dark-theme select,
body.light-theme select,
body.dark-theme textarea,
body.light-theme textarea {
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
    border-color: var(--border-color) !important;
    -webkit-text-fill-color: var(--input-text) !important;
}

body.dark-theme .modal-backdrop,
body.light-theme .modal-backdrop,
body.dark-theme .modal-overlay,
body.light-theme .modal-overlay {
    background: var(--modal-overlay) !important;
}


