/* =============================================
   OWEB SEO Dashboard - Premium Styles (RTL)
   ============================================= */

:root {
    /* OWEB Brand Colors */
    --primary: #4129da;
    --primary-dark: #3520b5;
    --primary-light: #e8e5fb;
    --primary-glow: rgba(65, 41, 218, 0.15);
    --secondary: #505edd;
    --accent: #7b6ef6;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #505edd;
    --info-light: #f2f2ff;

    /* Neutrals - OWEB palette */
    --bg: #f2f2ff;
    --bg-card: #ffffff;
    --bg-sidebar: #1b1159;
    --bg-sidebar-hover: #2a1f6e;
    --bg-sidebar-active: #4129da;
    --text: #303047;
    --text-secondary: #787d96;
    --text-light: #9b9fb5;
    --text-sidebar: #d9d6fa;
    --border: #d9d6fa;
    --border-light: #eeedf8;

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 1px 3px rgba(27,17,89,0.06), 0 1px 2px rgba(27,17,89,0.04);
    --shadow-md: 0 4px 16px rgba(27,17,89,0.08);
    --shadow-lg: 0 12px 48px rgba(27,17,89,0.12);
    --shadow-glow: 0 0 20px rgba(65,41,218,0.15);

    /* Transitions */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    /* Font */
    --font: 'Heebo', sans-serif;
}

/* =============================================
   Reset & Base
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    direction: rtl;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

::selection {
    background: var(--primary);
    color: white;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* =============================================
   Loading Screen
   ============================================= */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1b1159 0%, #2e2e44 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; }
.loading-logo-img {
    height: 52px;
    width: auto;
    margin-bottom: 2rem;
    opacity: 0.95;
}
.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   Login Page
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d0a2e;
    background: linear-gradient(160deg, #0d0a2e 0%, #1b1159 40%, #2004d4 100%);
    position: relative;
    overflow: hidden;
}

/* Animated background shapes */
.login-bg-shapes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.login-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.07;
    filter: blur(60px);
}
.login-shape-1 {
    width: 500px; height: 500px;
    background: #523cdd;
    top: -15%; right: -10%;
    animation: loginFloat1 15s ease-in-out infinite;
}
.login-shape-2 {
    width: 400px; height: 400px;
    background: #361dd8;
    bottom: -10%; left: -5%;
    animation: loginFloat2 18s ease-in-out infinite;
}
.login-shape-3 {
    width: 300px; height: 300px;
    background: #7b6ef6;
    top: 40%; left: 50%;
    animation: loginFloat3 12s ease-in-out infinite;
}
@keyframes loginFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 30px) scale(1.1); }
}
@keyframes loginFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -40px) scale(1.15); }
}
@keyframes loginFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-20px, -30px) scale(0.9); }
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 1.25rem;
    position: relative;
    z-index: 2;
}
.login-box {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 3rem 2.5rem 2rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.08);
    animation: loginFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Logo */
.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo-img {
    height: 48px;
    width: auto;
    margin-bottom: 0.75rem;
}
.login-logo-divider {
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #361dd8, #523cdd);
    border-radius: 3px;
    margin: 0 auto 0.6rem;
}
.login-logo-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Form fields */
.login-box .form-group { margin-bottom: 1.25rem; }
.login-box label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.4rem;
}
.login-box .input-icon {
    position: relative;
}
.login-box .input-icon i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
    transition: color var(--transition);
}
.login-box .input-icon input {
    width: 100%;
    padding: 0.8rem 2.8rem 0.8rem 1rem;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: all var(--transition);
    outline: none;
}
.login-box .input-icon input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px var(--primary-glow);
}
.login-box .input-icon input:focus + i,
.login-box .input-icon input:focus ~ i {
    color: var(--primary);
}

/* Error message */
.login-box .alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Submit button */
.login-btn {
    width: 100%;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #fff;
    background: linear-gradient(135deg, #361dd8 0%, #4129da 50%, #523cdd 100%);
    background-size: 200% 200%;
    box-shadow: 0 4px 15px rgba(54, 29, 216, 0.35);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.login-btn:hover {
    background-position: 100% 0;
    box-shadow: 0 6px 25px rgba(54, 29, 216, 0.45);
    transform: translateY(-1px);
}
.login-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(54, 29, 216, 0.3);
}
.login-btn-arrow {
    transition: transform 0.3s ease;
    font-size: 0.85rem;
}
.login-btn:hover .login-btn-arrow {
    transform: translateX(-4px);
}

/* Footer */
.login-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.8rem;
    color: var(--text-light);
}
.login-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.login-footer a:hover { text-decoration: underline; }

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

/* Mobile */
@media (max-width: 480px) {
    .login-box { padding: 2rem 1.5rem 1.5rem; border-radius: 16px; }
    .login-logo-img { height: 40px; }
}

/* =============================================
   Layout - Sidebar + Main
   ============================================= */
#app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1b1159 0%, #150e45 100%);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow);
    overflow-y: auto;
    border-left: 1px solid rgba(65,41,218,0.15);
}
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}
.sidebar-logo { font-size: 1.8rem; font-weight: 700; color: white; letter-spacing: 3px; }
.sidebar-logo-img { height: 32px; width: auto; opacity: 0.95; }
.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--accent);
    display: block;
    margin-top: 2px;
    letter-spacing: 1px;
}

/* Project Selector */
.project-selector {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.project-selector select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: white;
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}
.project-selector select:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.25);
}
.project-selector select option {
    background: var(--bg-sidebar);
    color: white;
}

/* Navigation */
.sidebar-nav { flex: 1; padding: 0.8rem 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 1.4rem;
    color: var(--text-sidebar);
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    border-right: 3px solid transparent;
    font-size: 0.9rem;
}
.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: white;
    border-right-color: rgba(255,255,255,0.2);
}
.nav-item.active {
    background: rgba(65,41,218,0.3);
    color: white;
    border-right-color: var(--accent);
}
.nav-item.active i { color: var(--accent); }
.nav-audit-badge {
    margin-right: auto;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 99px;
    padding: 0.1rem 0.45rem;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
    animation: badgePop 0.3s ease;
}
@keyframes badgePop {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    transition: color var(--transition);
}
/* Flat sidebar nav */
.sidebar-nav-flat > .nav-item {
    padding: 0.75rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 500;
}
.sidebar-nav-flat > .nav-item i {
    font-size: 1rem;
    width: 22px;
}

/* Nav Groups (legacy) */
.nav-group { margin-bottom: 0.15rem; }
.nav-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 1.2rem;
    cursor: pointer;
    color: var(--text-sidebar);
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.7;
    transition: opacity var(--transition);
    user-select: none;
}
.nav-group-header:hover { opacity: 1; }
.nav-group-header span { display: flex; align-items: center; gap: 0.5rem; }
.nav-group-header span i { width: 18px; text-align: center; font-size: 0.8rem; }
.nav-group-arrow { font-size: 0.55rem; transition: transform 0.3s ease; }
.nav-group.collapsed .nav-group-arrow { transform: rotate(-90deg); }
.nav-group-items {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.nav-group.collapsed .nav-group-items { max-height: 0; }
.nav-group-items .nav-item { padding-right: 2.8rem; font-size: 0.85rem; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 0.6rem 1.2rem;
}
.nav-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-light);
    padding: 0.6rem 1.4rem 0.3rem;
    letter-spacing: 1.5px;
}
.badge {
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 0.1rem 0.45rem;
    border-radius: 20px;
    margin-right: auto;
    min-width: 18px;
    text-align: center;
    font-weight: 600;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 1rem;
}
.user-info { display: flex; align-items: center; gap: 0.7rem; }
.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
    display: block;
    font-weight: 500;
    color: white;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role { display: block; font-size: 0.7rem; color: var(--accent); }

/* Main Content */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    max-width: 100vw;
}

/* =============================================
   Top Bar (enhanced)
   ============================================= */
.top-bar {
    height: var(--topbar-height);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.sidebar-toggle { display: none; width: 36px; height: 36px; font-size: 1.1rem; z-index: 200; }
.top-bar-title { flex: 1; }
.top-bar-title h1 { font-size: 1.2rem; font-weight: 600; }
.top-bar-actions { display: flex; align-items: center; gap: 0.6rem; }

/* Date Range Picker - Enhanced */
.date-range-picker {
    position: relative;
}
.date-range-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.date-range-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.date-range-btn i { color: var(--primary); font-size: 0.85rem; }
.date-range-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 200;
    min-width: 280px;
    padding: 0.5rem;
    display: none;
    animation: dropIn 0.2s ease-out;
}
.date-range-dropdown.open { display: block; }
@keyframes dropIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.date-range-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
}
.date-range-option:hover { background: var(--primary-light); color: var(--primary); }
.date-range-option.active { background: var(--primary); color: white; }
.date-range-option .date-hint { font-size: 0.75rem; opacity: 0.6; }
.date-range-divider { height: 1px; background: var(--border-light); margin: 0.3rem 0; }
.date-range-group-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); padding: 0.4rem 0.8rem 0.15rem; text-transform: uppercase; letter-spacing: 0.03em; }
.date-range-custom {
    padding: 0.6rem 0.8rem;
}
.date-range-custom label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.2rem;
}
.date-range-custom input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
}
.date-range-custom .flex {
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Global Search */
.global-search {
    position: relative;
}
.global-search input {
    width: 220px;
    padding: 0.45rem 0.8rem 0.45rem 2.2rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: var(--font);
    font-size: 0.82rem;
    background: var(--bg);
    transition: all var(--transition);
}
.global-search input:focus {
    width: 300px;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.global-search i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.85rem;
}
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 200;
    display: none;
    max-height: 340px;
    overflow-y: auto;
    animation: dropIn 0.2s ease-out;
}
.search-results-dropdown.open { display: block; }
.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-light);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }
.search-result-item i { color: var(--primary); width: 16px; text-align: center; font-size: 0.8rem; }
.search-result-item .result-label { flex: 1; }
.search-result-item .result-type { font-size: 0.7rem; color: var(--text-light); }
.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.82rem;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
    animation: contentFade 0.3s ease;
    overflow-x: hidden;
    max-width: 100%;
}
@keyframes contentFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================
   Cards (enhanced)
   ============================================= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow var(--transition), transform var(--transition);
    border: 1px solid rgba(217,214,250,0.3);
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-light);
}
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-title i { color: var(--primary); font-size: 0.9rem; }

/* Gradient Card */
.card-gradient {
    background: linear-gradient(135deg, #4129da 0%, #505edd 100%);
    color: white;
    border: none;
}
.card-gradient .card-title { color: white; }
.card-gradient .card-title i { color: rgba(255,255,255,0.8); }

/* =============================================
   Stat Cards (premium)
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all var(--transition);
    border: 1px solid rgba(217,214,250,0.2);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    opacity: 0;
    transition: opacity var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:nth-child(1)::before { background: var(--primary); }
.stat-card:nth-child(2)::before { background: var(--success); }
.stat-card:nth-child(3)::before { background: var(--warning); }
.stat-card:nth-child(4)::before { background: var(--secondary); }
.stat-card:nth-child(5)::before { background: var(--info); }
.stat-card:nth-child(6)::before { background: var(--danger); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: var(--primary-light); color: var(--secondary); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-icon.orange { background: #fff7ed; color: #f97316; }
.stat-icon.teal { background: #f0fdfa; color: #14b8a6; }

.stat-info { flex: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 0.15rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-change {
    font-size: 0.72rem;
    margin-top: 0.2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
}
.stat-change.up { color: var(--success); background: var(--success-light); }
.stat-change.down { color: var(--danger); background: var(--danger-light); }
.stat-change.same { color: var(--text-light); }

/* =============================================
   Dashboard V2 KPI Grid
   ============================================= */
.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.2rem;
}
.dash-kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dash-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.dash-kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.dash-kpi-body { flex: 1; min-width: 0; }
.dash-kpi-label { font-size: 0.72rem; color: var(--text-secondary); margin-bottom: 2px; }
.dash-kpi-value { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.dash-kpi-change { flex-shrink: 0; }

@media (max-width: 1200px) {
    .dash-kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
    .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .dash-kpi-grid { grid-template-columns: 1fr; }
    .dash-kpi-value { font-size: 1.1rem; }
}

/* =============================================
   Grids
   ============================================= */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.dash-hero-grid { display: grid; grid-template-columns: minmax(180px, 250px) repeat(3, 1fr); gap: 0.75rem; }

/* =============================================
   Buttons (refined)
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background var(--transition);
}
.btn:hover::after { background: rgba(255,255,255,0.1); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(65,41,218,0.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(65,41,218,0.4); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.78rem; }
.btn-xs { padding: 0.2rem 0.55rem; font-size: 0.72rem; line-height: 1.4; }
.gap-xs { gap: 0.35rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.7rem; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    padding: 0.4rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { color: var(--primary); background: var(--primary-light); }
.sidebar .btn-icon { color: var(--text-sidebar); }
.sidebar .btn-icon:hover { color: white; background: rgba(255,255,255,0.1); }

/* =============================================
   Forms (enhanced)
   ============================================= */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.input-icon { position: relative; }
.input-icon i {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    transition: color var(--transition);
}
.input-icon input:focus + i,
.input-icon input:focus ~ i { color: var(--primary); }
.input-icon input, .input-icon select { padding-right: 2.5rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="month"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    background: white;
    transition: all var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-light); }
textarea { resize: vertical; min-height: 80px; }

/* =============================================
   Alerts
   ============================================= */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}
.alert i { margin-top: 2px; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: #1b1159; border: 1px solid var(--border); }

/* =============================================
   Tables (enhanced)
   ============================================= */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 0.75rem 0.8rem;
    text-align: right;
    font-size: 0.83rem;
    border-bottom: 1px solid var(--border-light);
}
table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    white-space: nowrap;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
}
table th.sortable { cursor: pointer; user-select: none; }
table th.sortable:hover { color: var(--primary); }
table th.sortable::after { content: ' ↕'; font-size: 0.7rem; opacity: 0.4; }
table th.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--primary); }
table th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--primary); }
table tbody tr {
    transition: background var(--transition);
}
table tbody tr:hover { background: var(--primary-light); }
table tbody tr:active { background: #ddd8f5; }

/* Table pagination */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.pagination {
    display: flex;
    gap: 0.3rem;
}
.pagination button {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.82rem;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }

/* =============================================
   Tags & Badges (refined)
   ============================================= */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.2px;
}
.tag-active { background: var(--success-light); color: var(--success); }
.tag-paused { background: var(--warning-light); color: var(--warning); }
.tag-completed { background: var(--primary-light); color: var(--primary); }

/* =============================================
   Score Circles (animated)
   ============================================= */
.score-circle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    border: 3px solid;
    position: relative;
    transition: transform var(--transition);
}
.score-circle:hover { transform: scale(1.08); }
.score-good { border-color: var(--success); color: var(--success); background: rgba(16,185,129,0.05); }
.score-average { border-color: var(--warning); color: var(--warning); background: rgba(245,158,11,0.05); }
.score-poor { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.05); }

/* =============================================
   Health Score Gauge
   ============================================= */
.health-gauge {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto;
}
.health-gauge-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 8px solid var(--border-light);
}
.health-gauge-fill {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 8px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    transform: rotate(45deg);
    transition: all 1s ease;
}
.health-gauge-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}
.health-gauge-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

/* =============================================
   Empty State (improved)
   ============================================= */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}
.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 1.2rem;
    color: var(--border);
    display: block;
}
.empty-state h3 { margin-bottom: 0.5rem; font-weight: 600; color: var(--text); }
.empty-state p { max-width: 400px; margin: 0 auto; line-height: 1.7; }

/* =============================================
   Modal (refined)
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(27,17,89,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1.05rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-start;
    gap: 0.7rem;
}

/* =============================================
   Toast (refined)
   ============================================= */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: white;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.2rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 300px;
    max-width: 420px;
    animation: toastIn 0.35s ease-out;
    border-right: 4px solid;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast.info { border-color: var(--primary); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--primary); }
.toast-message { flex: 1; font-size: 0.83rem; }

@keyframes toastIn {
    from { transform: translateX(-30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-30px); opacity: 0; }
}

/* =============================================
   Tabs (refined)
   ============================================= */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab {
    padding: 0.7rem 1.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--primary-light); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.page-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    padding: 0 1.5rem;
}

/* =============================================
   Progress Bar
   ============================================= */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 10px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease;
}
.progress-fill.green { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-fill.yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill.red { background: linear-gradient(90deg, #ef4444, #f87171); }
.progress-fill.blue { background: linear-gradient(90deg, #4129da, #505edd); }

/* =============================================
   Skeleton (refined)
   ============================================= */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, #e8e5fb 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =============================================
   AI Chat (premium)
   ============================================= */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 3rem);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: repeating-linear-gradient(
        0deg, transparent, transparent 40px, rgba(65,41,218,0.02) 40px, rgba(65,41,218,0.02) 41px
    );
}
.chat-message {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    max-width: 75%;
    animation: msgIn 0.3s ease-out;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-message.user { margin-right: auto; flex-direction: row-reverse; }
.chat-message.ai { margin-left: auto; }
.chat-bubble {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    line-height: 1.6;
    box-shadow: var(--shadow);
}
.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-top-left-radius: 4px;
}
.chat-message.ai .chat-bubble {
    background: white;
    color: var(--text);
    border-top-right-radius: 4px;
    border: 1px solid var(--border-light);
}
.chat-input-bar {
    display: flex;
    gap: 0.6rem;
    padding: 1rem 1.2rem;
    border-top: 1px solid var(--border);
    background: white;
    border-radius: 0 0 var(--radius) var(--radius);
}
.chat-input-bar input { flex: 1; border-radius: 20px; padding-right: 1.2rem; }

/* =============================================
   Tooltip
   ============================================= */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    right: 50%;
    transform: translateX(50%);
    background: #303047;
    color: white;
    font-size: 0.72rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; }

/* =============================================
   Quick Actions Bar
   ============================================= */
.quick-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: var(--font);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.quick-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.quick-action-btn i { font-size: 0.85rem; }

/* =============================================
   Checklist
   ============================================= */
.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.checklist-item:hover { background: var(--primary-light); margin: 0 -0.5rem; padding-right: 0.5rem; padding-left: 0.5rem; border-radius: var(--radius-xs); }
.checklist-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.checklist-icon.pass { background: var(--success-light); color: var(--success); }
.checklist-icon.fail { background: var(--danger-light); color: var(--danger); }
.checklist-icon.warn { background: var(--warning-light); color: var(--warning); }
.checklist-icon.info { background: var(--info-light); color: var(--info); }
.checklist-text { flex: 1; }
.checklist-text strong { display: block; font-size: 0.85rem; }
.checklist-text span { font-size: 0.78rem; color: var(--text-secondary); }

/* =============================================
   Site Audit — Health Hero
   ============================================= */
.audit-hero {
    display: grid;
    grid-template-columns: auto 1px 1fr 1px 1fr;
    gap: 0;
    padding: 1.5rem;
    align-items: start;
}
.audit-hero-divider {
    width: 1px;
    background: var(--border);
    margin: 0 1.5rem;
    align-self: stretch;
}
.audit-hero-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-left: 1.5rem;
    min-width: 160px;
    text-align: center;
}
.audit-hero-issues,
.audit-hero-stats {
    padding: 0;
}
.audit-health-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 8px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 auto;
    transition: transform var(--transition);
    cursor: default;
}
.audit-health-circle:hover { transform: scale(1.05); }
.health-good    { border-color: var(--success); color: var(--success); background: rgba(16,185,129,0.06); }
.health-average { border-color: var(--warning); color: var(--warning); background: rgba(245,158,11,0.06); }
.health-poor    { border-color: var(--danger);  color: var(--danger);  background: rgba(239,68,68,0.06);  }

.audit-hero-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    margin-bottom: 0.65rem;
}

/* Issue tiers in hero */
.audit-issue-tiers {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.audit-issue-tier {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-xs);
}
.tier-critical { background: var(--danger-light);  }
.tier-warning  { background: var(--warning-light); }
.tier-info     { background: var(--info-light);    }
.tier-zero     { background: var(--success-light); }
.tier-count {
    font-size: 1.5rem;
    font-weight: 800;
    min-width: 2rem;
    text-align: center;
    line-height: 1;
}
.tier-critical .tier-count { color: var(--danger);  }
.tier-warning  .tier-count { color: var(--warning); }
.tier-info     .tier-count { color: var(--info);    }
.tier-zero     .tier-count { color: var(--success); }
.tier-label {
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.tier-critical .tier-label { color: var(--danger);  }
.tier-warning  .tier-label { color: var(--warning); }
.tier-info     .tier-label { color: var(--info);    }
.tier-zero     .tier-label { color: var(--success); }

/* Quick stats rows */
.audit-stat-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-light);
}
.audit-stat-row:last-child { border-bottom: none; }

/* ── Ahrefs-style Issues Table ───────────────────────────────── */
.audit-issues-table {
    width: 100%;
    border-collapse: collapse;
}
.audit-issues-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.55rem 0.8rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    background: var(--bg);
}
.audit-issues-table td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.issue-row:hover td { background: var(--primary-light); }
.issue-row:last-child td { border-bottom: none; }
.issue-sev-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 99px;
    font-size: 0.73rem;
    font-weight: 700;
    white-space: nowrap;
}
.issue-cat-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.issue-pct-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    min-width: 50px;
}
.issue-pct-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* Issue categories (legacy — used in hero only) */
.issue-category { margin-bottom: 0.6rem; }
.issue-cat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
    border: 1px solid;
}
.issue-cat-count {
    margin-right: auto;
    font-size: 0.72rem;
    font-weight: 600;
    opacity: 0.8;
}
.issue-item {
    border: 1px solid;
    border-top: none;
    padding: 0.5rem 0.8rem;
}
.issue-item:last-child { border-radius: 0 0 var(--radius-xs) var(--radius-xs); }
.issue-item-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
}
.issue-count-badge {
    margin-right: auto;
    border-radius: 99px;
    padding: 0.1rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.issue-fix-hint {
    font-size: 0.76rem;
    color: var(--text-secondary);
    padding-right: 1.4rem;
    line-height: 1.4;
}

/* Responsive: stack on narrow screens */
@media (max-width: 900px) {
    .audit-hero {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .audit-hero-divider {
        width: 100%;
        height: 1px;
        margin: 1rem 0;
        align-self: auto;
    }
    .audit-hero-score { padding-left: 0; padding-bottom: 1rem; min-width: unset; }
}

/* =============================================
   Competitor Row
   ============================================= */
.competitor-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}
.competitor-rank {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.competitor-rank.gold { background: #fef3c7; color: #d97706; }
.competitor-rank.silver { background: #f1f5f9; color: #475569; }
.competitor-rank.bronze { background: #fed7aa; color: #c2410c; }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 1024px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .dash-hero-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .dash-hero-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .dash-hero-grid { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); z-index: 1000; }
    .sidebar.open { transform: translateX(0); box-shadow: -5px 0 30px rgba(0,0,0,0.4); }
    .main-content { margin-right: 0; }
    .sidebar-toggle { display: flex !important; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .modal { max-width: calc(100vw - 2rem); }
    .global-search input, .global-search input:focus { width: 160px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 0.75rem; }
    .top-bar { padding: 0 0.75rem; gap: 0.5rem; }
    .top-bar-title h1 { font-size: 1rem; }
    .date-range-btn { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
    .global-search { display: none; }
}

/* =============================================
   Global overflow prevention
   ============================================= */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }

/* =============================================
   Mobile-Friendly — Tablet (≤768px)
   ============================================= */
@media (max-width: 768px) {
    /* Prevent ANY horizontal overflow */
    .main-content, .page-content, #page-content { overflow-x: hidden !important; max-width: 100vw !important; }
    .card { max-width: 100% !important; overflow: hidden; }
    .card-body { overflow-x: auto !important; max-width: 100%; }

    /* FORCE all display:grid with inline styles to stack */
    div[style*="display:grid"],
    div[style*="display: grid"],
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    /* KPI grids: keep multi-column (override the 1fr above) */
    div[style*="repeat(auto-fit"] {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
    }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }

    /* Buttons */
    .btn { font-size: 0.78rem; padding: 0.4rem 0.65rem; }
    a.btn { text-decoration: none; }

    /* Tables: horizontal scroll inside card */
    .table, table { font-size: 0.76rem; white-space: nowrap; min-width: 0; }
    .card-body { padding: 0.5rem; overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .card-header { padding: 0.5rem 0.75rem; }
    .card-header h3 { font-size: 0.88rem; word-break: break-word; }

    /* Scrollable table wrapper */
    .card-body:has(table),
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Modal full-screen */
    .modal { max-width: 100vw !important; width: 100vw !important; margin: 0 !important; border-radius: 0 !important; max-height: 100vh !important; }
    .modal-body { max-height: 75vh; overflow-y: auto; }

    /* Flex wraps everywhere + prevent overflow */
    .flex-between,
    div[style*="display:flex"],
    div[style*="display: flex"] { flex-wrap: wrap !important; max-width: 100%; }

    /* Inline styles with fixed widths */
    div[style*="width:100px"], span[style*="width:100px"] { width: auto !important; }
    div[style*="width:80px"], span[style*="width:80px"] { width: auto !important; }
    div[style*="min-width:200px"] { min-width: 0 !important; }

    /* Top bar */
    .top-bar-actions { gap: 0.3rem; }
    #sync-btn { padding: 0.25rem 0.5rem; }
    .top-bar-title h1 { font-size: 1.05rem; }

    /* Sidebar: full overlay */
    .sidebar { width: 240px; }

    /* Charts max height */
    canvas { max-height: 250px !important; }

    /* ROI sub-rows indent less */
    td[style*="padding-right:2.5rem"],
    td[style*="padding-right:3rem"],
    td[style*="padding-right: 2.5rem"],
    td[style*="padding-right: 3rem"] { padding-right: 1.2rem !important; }

    /* Stat cards in grids */
    .stat-card { padding: 0.6rem; }
    .stat-card .stat-value { font-size: 1.1rem; }

    /* Date range dropdown */
    .date-range-dropdown { left: auto; right: 0; min-width: 250px; }
}

/* =============================================
   Mobile-Friendly — Phone (≤480px)
   ============================================= */
@media (max-width: 480px) {
    /* KPI grids: 2 per row */
    .page-content div[style*="repeat(auto-fit"],
    #page-content div[style*="repeat(auto-fit"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* All other grids single column */
    .page-content div[style*="display:grid"]:not([style*="repeat(auto-fit"]),
    #page-content div[style*="display:grid"]:not([style*="repeat(auto-fit"]) {
        grid-template-columns: 1fr !important;
    }

    /* Smaller font overrides — use * selector for inline styles */
    .page-content *, #page-content * {
        --mobile-scale: 0.85;
    }
    .card [style*="font-size:1.5rem"],
    .card [style*="font-size: 1.5rem"] { font-size: 1.05rem !important; }
    .card [style*="font-size:1.4rem"],
    .card [style*="font-size: 1.4rem"] { font-size: 1rem !important; }
    .card [style*="font-size:1.3rem"],
    .card [style*="font-size: 1.3rem"] { font-size: 0.92rem !important; }
    .card [style*="font-size:1.2rem"],
    .card [style*="font-size: 1.2rem"] { font-size: 0.88rem !important; }
    .card [style*="font-size:1.1rem"],
    .card [style*="font-size: 1.1rem"] { font-size: 0.82rem !important; }

    /* Buttons */
    .btn { font-size: 0.7rem; padding: 0.3rem 0.45rem; }

    /* Page content less padding */
    .page-content { padding: 0.5rem; }

    /* Tables */
    .table, table { font-size: 0.7rem; }
    th, td { padding: 0.3rem 0.4rem !important; }

    /* Cards compact */
    .card { border-radius: 6px; }
    .card-body { padding: 0.35rem; }
    .card-header { padding: 0.4rem 0.6rem; }

    /* Hide search */
    .global-search { display: none; }

    /* Top bar compact */
    .top-bar { padding: 0 0.5rem; height: 44px; }
    .top-bar-title h1 { font-size: 0.88rem; }
    .date-range-btn { font-size: 0.68rem; padding: 0.2rem 0.35rem; }

    /* Modal compact */
    .modal table td,
    .modal table th { padding: 0.25rem 0.2rem; font-size: 0.75rem; }
    .modal table input { font-size: 0.75rem; padding: 0.2rem 0.3rem; }
    .modal h1, .modal h2, .modal h3 { font-size: 1rem; }

    /* Sidebar smaller */
    .sidebar { width: 200px; }
    .nav-item span { font-size: 0.8rem; }
    .nav-group-header span { font-size: 0.82rem; }

    /* Dashboard hero */
    .dash-hero-grid { grid-template-columns: 1fr !important; gap: 0.5rem; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 0.5rem; }

    /* Health gauge smaller */
    .health-gauge { width: 100px; height: 100px; }

    /* Funnel */
    div[style*="width:100px"] { width: 55px !important; font-size: 0.68rem !important; }

    /* Channel bars overflow */
    div[style*="width:45px"], div[style*="width:50px"], div[style*="width:60px"] { display: none !important; }

    /* WooCommerce tabs */
    a.btn, button.btn { white-space: nowrap; }
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
    .sidebar, .top-bar, .btn, .chat-input-bar, .modal-overlay { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    body { background: white !important; }
}

/* =============================================
   Utility
   ============================================= */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-secondary); }
.text-small { font-size: 0.78rem; }
.text-xs { font-size: 0.7rem; }
.font-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clickable { cursor: pointer; }
.no-select { user-select: none; }

/* =============================================
   Conversions Page
   ============================================= */
.funnel-container { display: flex; flex-direction: column; gap: 0.5rem; }
.funnel-step { display: flex; flex-direction: column; gap: 0.3rem; }
.funnel-label { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 0 0.25rem; }
.funnel-bar-wrapper { width: 100%; background: var(--bg-secondary); border-radius: 8px; overflow: hidden; height: 36px; }
.funnel-bar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    border-radius: 8px;
    transition: width 0.6s ease;
    min-width: 40px;
}
.funnel-bar-0 { background: linear-gradient(135deg, #6366f1, #818cf8); }
.funnel-bar-1 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.funnel-bar-2 { background: linear-gradient(135deg, #10b981, #34d399); }
.funnel-drop {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.source-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 100px;
}
.source-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 2px;
}
.source-bar-wrapper span { font-size: 0.72rem; color: var(--text-secondary); white-space: nowrap; }

.revenue-highlight { font-weight: 600; color: var(--success); }

/* =============================================
   CWV Mini Widget (Dashboard)
   ============================================= */
.cwv-mini {
    display: flex;
    justify-content: space-around;
    padding: 0.8rem;
}
.cwv-mini-value {
    font-size: 1.3rem;
    font-weight: 700;
}

/* =============================================
   Opportunity Badge (Keywords)
   ============================================= */
.opportunity-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.opportunity-high { background: #dcfce7; color: #16a34a; }
.opportunity-medium { background: #fef9c3; color: #ca8a04; }

/* =============================================
   Severity Colors (Notifications)
   ============================================= */
.notif-critical { border-right: 4px solid var(--danger); }
.notif-warning { border-right: 4px solid var(--warning); }
.notif-info { border-right: 4px solid #3b82f6; }

/* =============================================
   Difficulty Tags (Keywords)
   ============================================= */
.diff-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}
.diff-easy { background: #dcfce7; color: #16a34a; }
.diff-medium { background: #fef9c3; color: #ca8a04; }
.diff-hard { background: #fee2e2; color: #dc2626; }

/* =============================================
   Funnel Visualization
   ============================================= */
.funnel-visual { padding: 1rem 0; }
.funnel-step { margin-bottom: 0.25rem; }
.funnel-bar {
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    transition: width 0.5s ease;
}
.funnel-bar-0 { background: #4129da; }
.funnel-bar-1 { background: #6366f1; }
.funnel-bar-2 { background: #f59e0b; }
.funnel-bar-3 { background: #22c55e; }
.funnel-dropoff {
    text-align: center;
    padding: 0.2rem 0;
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.funnel-dropoff .rate { font-weight: 600; }
.funnel-dropoff .rate.good { color: var(--success); }
.funnel-dropoff .rate.poor { color: var(--danger); }

/* Dropoff Analysis Cards */
.dropoff-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.dropoff-card {
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    text-align: center;
}
.dropoff-card .step-label { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.dropoff-card .step-rate { font-size: 1.5rem; font-weight: 700; }

/* =============================================
   Margin Summary
   ============================================= */
.margin-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.margin-box {
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    text-align: center;
}
.margin-box .value { font-size: 1.3rem; font-weight: 700; }
.margin-box .label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.3rem; }

/* =============================================
   Cohort Matrix
   ============================================= */
.cohort-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.cohort-table th,
.cohort-table td { padding: 0.4rem 0.6rem; text-align: center; border: 1px solid var(--border-light); }
.cohort-table th { background: var(--bg); font-weight: 600; font-size: 0.72rem; }
.cohort-table .cohort-cell { min-width: 60px; }
.cohort-heat-0 { background: #f0fdf4; }
.cohort-heat-1 { background: #bbf7d0; }
.cohort-heat-2 { background: #86efac; }
.cohort-heat-3 { background: #4ade80; color: white; }
.cohort-heat-4 { background: #22c55e; color: white; }

.ltv-summary { display: flex; gap: 2rem; padding: 1rem 0; }
.ltv-stat { text-align: center; }
.ltv-stat .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.ltv-stat .label { font-size: 0.75rem; color: var(--text-secondary); }

/* =============================================
   Campaign Badge
   ============================================= */
.campaign-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.campaign-good { background: var(--success-light); color: var(--success); }
.campaign-medium { background: var(--warning-light); color: var(--warning); }
.campaign-poor { background: var(--danger-light); color: var(--danger); }

@media (max-width: 768px) {
    .margin-summary { grid-template-columns: repeat(2, 1fr); }
    .dropoff-grid { grid-template-columns: 1fr; }
}

/* =============================================
   Link Monitor
   ============================================= */
.link-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
}
.link-status-dot.green { background: var(--success); }
.link-status-dot.yellow { background: var(--warning); }
.link-status-dot.red { background: var(--danger); }
.link-status-dot.gray { background: var(--text-light); }

.response-fast { color: var(--success); font-weight: 600; }
.response-medium { color: var(--warning); font-weight: 600; }
.response-slow { color: var(--danger); font-weight: 600; }

/* ===========================
   Diagram Treemap - Site Structure
   =========================== */
#diagram-canvas {
    user-select: none;
}
#diagram-canvas > div {
    will-change: transform;
}
#diagram-breadcrumb a:hover {
    opacity: 1 !important;
    text-decoration: underline !important;
}

/* ===========================
   URL Tree - Site Structure
   =========================== */
.url-tree {
    font-size: 0.82rem;
    direction: ltr;
}

.tree-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    user-select: none;
}

.tree-header:hover {
    background: var(--bg-secondary);
}

.tree-toggle {
    width: 16px;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform 0.15s;
}

.tree-item:not(.expanded) > .tree-header > .tree-toggle > i.fa-chevron-down {
    transform: rotate(-90deg);
}

.tree-icon {
    color: var(--primary);
    font-size: 0.8rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.tree-label {
    font-weight: 500;
    flex-shrink: 0;
}

.tree-count {
    font-size: 0.68rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.tree-status-dots {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

.status-pip {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.tree-gsc, .tree-gsc-leaf {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tree-gsc-leaf {
    font-size: 0.68rem;
    margin-left: 0;
}

.tree-response-time {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.tree-children {
    padding-left: 1.2rem;
    border-left: 1px dashed var(--border);
    margin-left: 0.7rem;
}

.tree-leaf {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    border-radius: 4px;
}

.tree-leaf:hover {
    background: var(--bg-secondary);
}

.tree-leaf-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tree-leaf-url {
    color: var(--text-primary);
    text-decoration: none;
}

.tree-leaf-url:hover {
    color: var(--primary);
    text-decoration: underline;
}

.tree-status-code {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0 0.3rem;
    border-radius: 3px;
    background: var(--bg-secondary);
}

.tree-inspect {
    opacity: 0;
    transition: opacity 0.15s;
}

.tree-leaf:hover .tree-inspect {
    opacity: 1;
}

/* Button group (view toggle) */
.btn-group {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
}
.btn-group .btn {
    border-radius: 0;
}
.btn-group .btn:first-child { border-radius: 0 6px 6px 0; }
.btn-group .btn:last-child { border-radius: 6px 0 0 6px; }
.btn-group .btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ══════════════════════════════════════════════════
   Tasks & Changelog Page
══════════════════════════════════════════════════ */

/* Tab bar */
.tasks-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.tasks-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    border-radius: 6px 6px 0 0;
}
.tasks-tab:hover { color: var(--primary); }
.tasks-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.tasks-tab-badge {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    min-width: 1.2rem;
    text-align: center;
}
.tasks-tab:not(.active) .tasks-tab-badge {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* ── Link Monitor Tabs ─────────────────────────────────────────────────────── */
.link-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}
.link-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    background: none;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    border-radius: 6px 6px 0 0;
}
.link-tab:hover { color: var(--primary); }
.link-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.link-tab-count {
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    min-width: 1.2rem;
    text-align: center;
}
.link-tab.active .link-tab-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* Filter bar */
.tasks-filter-bar {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.tasks-filter {
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.tasks-filter:hover { border-color: var(--primary); color: var(--primary); }
.tasks-filter.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

/* Task card */
.task-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.task-card:hover { box-shadow: 0 2px 8px rgba(65,41,218,0.1); border-color: #c4b8f8; }
.task-card.task-done { opacity: 0.6; }

.task-priority-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.35rem;
}
.task-card-left { display: flex; align-items: flex-start; padding-top: 0.1rem; }

.task-card-body { flex: 1; min-width: 0; }
.task-card-title { font-weight: 600; font-size: 0.95rem; color: var(--text); margin-bottom: 0.2rem; }
.task-card-desc  { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.4rem;
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.task-card-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.task-cat-badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.task-due { font-size: 0.78rem; color: var(--text-secondary); }
.task-due.overdue { color: #dc2626; font-weight: 600; }

.task-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; flex-shrink: 0; }

.task-status-badge {
    padding: 0.25rem 0.7rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
    border: none; cursor: pointer; transition: filter 0.15s; white-space: nowrap;
}
.task-status-badge:hover { filter: brightness(0.9); }

.task-actions { display: flex; gap: 0.25rem; }
.btn-icon {
    width: 28px; height: 28px; border: none; border-radius: 6px; background: var(--bg-secondary);
    color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; transition: all 0.15s;
}
.btn-icon:hover { background: var(--primary); color: white; }
.btn-icon.danger:hover { background: #dc2626; color: white; }

/* Changelog timeline */
.changelog-timeline { padding: 0.5rem 0; }

.changelog-month-label {
    font-size: 0.8rem; font-weight: 700; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 1rem 0 0.5rem 0; border-bottom: 1px solid var(--border); margin-bottom: 0.5rem;
}

.changelog-entry {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.25rem 0 1rem 0;
    position: relative;
}
.changelog-entry::before {
    content: '';
    position: absolute;
    right: 7px;
    top: 1.2rem;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.changelog-entry:last-child::before { display: none; }

.changelog-dot {
    width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
    margin-top: 0.3rem; border: 2px solid white; box-shadow: 0 0 0 2px var(--border);
    position: relative; z-index: 1;
}

.changelog-card {
    flex: 1; background: white; border: 1px solid var(--border);
    border-radius: 10px; padding: 0.75rem 1rem; min-width: 0;
}
.changelog-card-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem;
}
.changelog-card-title { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.changelog-card-right { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.changelog-impact {
    display: inline-flex; align-items: center; gap: 0.2rem;
    padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.changelog-date { font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; }
.changelog-card-desc { font-size: 0.83rem; color: var(--text-secondary); margin-bottom: 0.4rem; line-height: 1.5; }
.changelog-card-footer { display: flex; gap: 0.75rem; align-items: center; font-size: 0.78rem; color: var(--text-secondary); }
.changelog-user, .changelog-task-link { display: flex; align-items: center; gap: 0.25rem; }
.changelog-task-link { color: var(--primary); }

/* Screenshot paste zone */
.screenshot-paste-zone {
    border: 2px dashed #d9d6fa;
    border-radius: 8px;
    padding: 1.1rem;
    text-align: center;
    cursor: pointer;
    color: #9ca3af;
    transition: border-color 0.2s, color 0.2s, background 0.2s, opacity 0.2s;
    outline: none;
    user-select: none;
}
.screenshot-paste-zone:hover,
.screenshot-paste-zone:focus {
    border-color: var(--primary);
    color: var(--primary);
    background: #f2f2ff;
}
.screenshot-paste-zone i { font-size: 1.3rem; display: block; margin-bottom: 0.35rem; }
.screenshot-paste-zone span { font-size: 0.82rem; }
/* Thumbnail grid — inside modal */
.screenshot-thumb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.screenshot-thumb {
    position: relative;
    width: 90px; height: 72px;
    border-radius: 6px;
    overflow: visible;
    flex-shrink: 0;
}
.screenshot-thumb img {
    width: 90px; height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #d9d6fa;
    cursor: zoom-in;
    display: block;
    transition: opacity 0.15s;
}
.screenshot-thumb img:hover { opacity: 0.82; }
.screenshot-remove {
    position: absolute; top: -7px; right: -7px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #ef4444; color: #fff; border: none;
    cursor: pointer; font-size: 12px; line-height: 20px;
    text-align: center; padding: 0; z-index: 2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: background 0.15s;
}
.screenshot-remove:hover { background: #dc2626; }
/* Screenshot grid in changelog timeline */
.changelog-screenshot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.4rem 0 0.2rem;
}
.changelog-screenshot-grid img {
    height: 80px; max-width: 130px;
    border-radius: 5px; border: 1px solid #d9d6fa;
    cursor: zoom-in; object-fit: cover;
    transition: opacity 0.15s, transform 0.15s;
}
.changelog-screenshot-grid img:hover { opacity: 0.85; transform: scale(1.03); }
/* Lightbox */
.screenshot-lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; animation: fadeIn 0.15s;
}
.screenshot-lightbox-content {
    position: relative; max-width: 92vw; max-height: 92vh; cursor: default;
}
.screenshot-lightbox-content img {
    max-width: 92vw; max-height: 90vh;
    border-radius: 8px; display: block;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.screenshot-lightbox-close {
    position: absolute; top: -14px; right: -14px;
    width: 28px; height: 28px; border-radius: 50%;
    background: #ef4444; color: #fff; border: none;
    cursor: pointer; font-size: 16px; line-height: 28px;
    text-align: center; padding: 0; z-index: 1;
}

/* ══════════════════════════════════════════════════
   Content Ideas Page
══════════════════════════════════════════════════ */

.ci-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.6rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.ci-card:hover { box-shadow: 0 2px 10px rgba(65,41,218,0.1); border-color: #c4b8f8; }

.ci-card-score {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.ci-card-body { flex: 1; min-width: 0; }
.ci-card-header { margin-bottom: 0.3rem; }

.ci-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    font-size: 0.73rem;
    font-weight: 700;
}

.ci-card-topic {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.ci-card-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.ci-card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-shrink: 0;
    align-items: flex-end;
}

/* ── Project Cards ─────────────────────────────────────── */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}
.project-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.project-card:hover {
    box-shadow: 0 4px 20px rgba(65,41,218,0.1);
    transform: translateY(-2px);
}
.project-card-skeleton {
    height: 200px;
    background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.1rem 0.7rem;
    gap: 0.5rem;
}
.project-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
}
.project-card-domain {
    font-size: 0.78rem;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.project-card-domain:hover { text-decoration: underline; }

.project-card-connections {
    padding: 0.7rem 1.1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex: 1;
}
.conn-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}
.conn-badges-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.conn-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
}
.conn-ok  { border-color: var(--success); color: var(--success); background: var(--success-light, #f0fdf4); }
.conn-off { border-color: var(--border);  color: var(--text-light); background: var(--bg-secondary, #f8f8f8); }
.conn-hint {
    margin-top: 0.5rem;
    font-size: 0.73rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.project-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1.1rem;
    gap: 0.5rem;
}
.project-card-stats {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-light);
}
.project-card-stats i { color: var(--primary); }

/* ── Modal Tabs ───────────────────────────────────────── */
.modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin: -0.25rem -0.25rem 1.25rem;
}
.modal-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    margin-bottom: -2px;
    transition: color 0.15s;
    white-space: nowrap;
}
.modal-tab:hover { color: var(--primary); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-conn-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
}
.pill-ok  { background: var(--success-light, #f0fdf4); color: var(--success); }
.pill-warn { background: #fef3c7; color: #d97706; }
.pill-off  { background: #fef2f2; color: var(--danger); }

.tab-count {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

.modal-tab-pane { display: none; }
.modal-tab-pane.active { display: block; }

/* ── Connections blocks inside modal ─────────────────── */
.conn-block {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    margin-bottom: 0.7rem;
    overflow: hidden;
    transition: border-color 0.2s;
}
.conn-block-ok  { border-color: var(--success); }
.conn-block-off { border-color: var(--border); }
.conn-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0.9rem;
    gap: 0.5rem;
    background: var(--bg);
}
.conn-block-note {
    font-size: 0.75rem;
    color: var(--text-light);
    padding: 0.4rem 0.9rem 0.6rem;
    background: var(--bg);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ── Clients tab ─────────────────────────────────────── */
.proj-clients-section { padding: 0.25rem 0; }
.proj-clients-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
}
.proj-client-row {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.proj-client-row:last-child { border-bottom: none; }
.proj-client-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ── Automations Grid ────────────────────────────── */
.auto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.auto-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.auto-card:hover {
    box-shadow: 0 4px 12px rgba(65, 41, 218, 0.08);
    border-color: #c4b8f8;
}

.auto-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.auto-card-body {
    flex: 1;
    min-width: 0;
}

.auto-card-body h4 {
    margin: 0 0 0.2rem;
    font-size: 0.95rem;
}

.auto-result-content {
    line-height: 1.8;
    font-size: 0.9rem;
    padding: 1.5rem;
}
.auto-result-content h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; color: #1f2937; }
.auto-result-content h3 { font-size: 1.05rem; margin: 1.2rem 0 0.4rem; color: #374151; }
.auto-result-content h4 { font-size: 0.95rem; margin: 1rem 0 0.3rem; color: #4b5563; }
.auto-result-content table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; }
.auto-result-content td,
.auto-result-content th { padding: 0.4rem 0.6rem; border: 1px solid var(--border-light); text-align: right; font-size: 0.85rem; }
.auto-result-content th { background: #f9fafb; font-weight: 600; }
.auto-result-content code { background: #f3f4f6; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.85em; }
.auto-result-content pre { background: #1f2937; color: #e5e7eb; padding: 1rem; border-radius: 8px; overflow-x: auto; margin: 0.5rem 0; }
.auto-result-content pre code { background: none; color: inherit; padding: 0; }
.auto-result-content ul { padding-right: 1.2rem; margin: 0.3rem 0; }
.auto-result-content li { margin-bottom: 0.3rem; }
.auto-result-content hr { border: none; border-top: 1px solid var(--border-light); margin: 1rem 0; }

.auto-task-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

/* Usage stats */
.usage-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.usage-stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.usage-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.usage-stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}
@media (max-width: 768px) {
    .usage-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Automation progress ring */
.auto-progress-ring {
    position: relative;
    width: 90px;
    height: 90px;
    margin: 0 auto;
}
.auto-progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.auto-progress-track { fill: none; stroke: #e5e7eb; stroke-width: 5; }
.auto-progress-fill {
    fill: none;
    stroke: var(--color, #4129da);
    stroke-width: 5;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}
.auto-progress-ring span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.auto-step {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0 0.5rem;
    opacity: 0.3;
    transition: opacity 0.4s;
}
.auto-step.active { opacity: 1; color: var(--primary); }


/* ── Connections page — refined ──────────────────────────────────── */
.connections-page { padding: 0; }
.conn-page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.conn-page-actions { display: flex; gap: 12px; align-items: center; }

.connections-grid { display: flex; flex-direction: column; gap: 28px; }
.conn-group-title {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.conn-group-title i { color: var(--primary, #4129da); }

.conn-card-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}
.conn-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.15s, transform 0.15s;
    position: relative;
}
.conn-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.07); transform: translateY(-1px); }

.conn-card-header { display: flex; align-items: center; gap: 14px; }
.conn-icon-wrap {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.conn-title-block { flex: 1; min-width: 0; }
.conn-title {
    font-weight: 600; font-size: 15px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conn-status {
    font-size: 12px; font-weight: 500; margin-top: 2px;
    display: flex; align-items: center; gap: 4px;
}

.conn-detail {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
}

.conn-badge-headline {
    display: flex; align-items: baseline; gap: 6px;
    padding: 8px 0; border-bottom: 1px solid var(--border-light, #f1f5f9);
}
.conn-badge-num { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.conn-badge-lbl { font-size: 12px; color: var(--text-muted); }

.conn-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    font-size: 12px;
}
.conn-field-label { color: var(--text-muted); font-size: 11px; }
.conn-field-value {
    font-weight: 500; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    direction: ltr; text-align: right;
}

.conn-meta {
    font-size: 11px; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
}

.conn-actions {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-top: auto; padding-top: 8px;
    border-top: 1px solid var(--border-light, #f1f5f9);
}
.conn-test-result { font-size: 12px; min-height: 16px; }

/* ── Inline modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 90%; max-width: 520px;
    max-height: 85vh;
    display: flex; flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
}
.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
    background: none; border: 0;
    font-size: 26px; line-height: 1; cursor: pointer;
    color: var(--text-muted);
    padding: 0; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
}
.modal-close:hover { background: var(--bg-secondary, #f8f8f8); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ── CardCom transactions tab ─────────────────────────────────────── */
.cc-tx-toolbar {
    display: flex; flex-wrap: wrap; gap: 14px;
    align-items: flex-end;
    margin-bottom: 16px;
}
.cc-tx-filter { display: flex; flex-direction: column; gap: 4px; }
.cc-tx-filter label { font-size: 12px; color: var(--text-muted); }
.cc-tx-filter input[type="date"], .cc-tx-filter input[type="text"] {
    padding: 7px 10px; border-radius: 6px;
    border: 1px solid var(--border, #e5e7eb);
    font-size: 14px;
}

.cc-stats-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.cc-stat-card {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-right: 4px solid;
    border-radius: 8px;
    padding: 12px 14px;
}
.cc-stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.cc-stat-value { font-size: 18px; font-weight: 700; color: var(--text-primary); }

.cc-tx-table-card { padding: 0; }
.cc-tx-status { padding: 8px 14px; color: var(--text-muted); font-size: 12px; }
.cc-tx-table { font-size: 12px; }
.cc-tx-table th { background: #f8f9fa; font-weight: 600; padding: 10px 8px; }
.cc-tx-table td { padding: 8px; border-bottom: 1px solid #f1f5f9; }
.cc-tx-table code { background: rgba(0,0,0,0.04); padding: 2px 5px; border-radius: 4px; }
.cc-tx-table .cc-row-refund { background: rgba(220,53,69,0.04); }

.cc-tx-pager { padding: 14px; text-align: center; }
.cc-tx-pager .btn { font-size: 13px; }

/* ── CardCom transactions: dual KPI cards ─────────────────────────── */
.cc-range-display {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 12px;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
.cc-range-display b { color: var(--text-primary); direction: ltr; }
.cc-range-display i { color: var(--primary, #4129da); }

.cc-stat-card {
    /* override the single-block layout */
    padding: 10px 14px;
}
.cc-stat-row {
    display: flex; gap: 12px; align-items: stretch;
}
.cc-stat-block { flex: 1; min-width: 0; }
.cc-stat-block-total {
    border-right: 1px solid var(--border-light, #f1f5f9);
    padding-right: 10px;
}
.cc-stat-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.cc-stat-value { font-size: 16px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.cc-stat-value-total { color: var(--text-muted); font-weight: 600; }
.cc-stat-pct { font-size: 11px; font-weight: 500; }

/* ── Organic monthly report ──────────────────────────────────────── */
.org-report-header { display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap; }
.org-report-controls { display:flex; align-items:center; gap:8px; }
.org-report-controls label { font-size:13px; color:var(--text-muted); }
.org-report-controls input[type="month"] { padding:6px 10px; border-radius:6px; border:1px solid var(--border); }

.org-period-banner {
    display:flex; justify-content:space-between; align-items:center;
    background: linear-gradient(135deg, rgba(65,41,218,0.08), rgba(65,41,218,0.02));
    border-right: 4px solid var(--primary, #4129da);
    margin-bottom: 24px;
}
.org-period-tag { color: var(--text-muted); font-size: 13px; }
.org-period-month { font-size: 22px; font-weight: 700; color: var(--primary, #4129da); margin-right: 8px; }
.org-period-range { color: var(--text-muted); font-size: 13px; margin-right: 12px; direction: ltr; }
.org-period-vs { color: var(--text-muted); font-size: 14px; }

.org-section-title {
    margin: 28px 0 12px;
    font-size: 17px;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}
.org-section-title i { color: var(--primary, #4129da); }

.org-kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px;
}
.org-kpi {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    padding: 14px 16px;
}
.org-kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.org-kpi-value { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.org-kpi-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; }
.org-kpi-prev { color: var(--text-muted); }
.org-kpi-delta { font-weight: 600; }

.org-share-row { display: flex; align-items: center; justify-content: space-around; padding: 24px; }
.org-share-block { text-align: center; }
.org-share-label { font-size: 12px; color: var(--text-muted); }
.org-share-pct   { font-size: 36px; font-weight: 700; color: var(--primary, #4129da); margin: 8px 0; }
.org-share-detail { font-size: 12px; color: var(--text-muted); }
.org-share-arrow { text-align: center; font-size: 14px; }

/* Print: hide chrome, expand cards */
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .page-tabs, .org-report-controls,
    #org-load, #org-print, #org-download { display: none !important; }
    .main-content, #page-content { padding: 0 !important; margin: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .org-section-title { page-break-after: avoid; }
    .org-kpi-grid, .org-share-row { page-break-inside: avoid; }
}

/* ── Organic report: investment + ROI hero ──────────────────────── */
.org-roi-hero {
    display: flex; align-items: center;
    gap: 24px; padding: 24px;
    background: linear-gradient(135deg, #4129da 0%, #6b46c1 100%);
    color: #fff;
    border-radius: 12px;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(65,41,218,0.25);
}
.org-roi-hero-main { text-align: center; flex-shrink: 0; }
.org-roi-hero-value {
    font-size: 60px; font-weight: 800; line-height: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.org-roi-hero-delta { font-size: 13px; margin-top: 6px; opacity: 0.95; }
.org-roi-hero-side { flex: 1; min-width: 0; }
.org-roi-hero-label { font-size: 14px; font-weight: 600; opacity: 0.85; }
.org-roi-hero-formula { font-size: 12px; opacity: 0.7; margin-top: 4px; direction: ltr; text-align: right; }
.org-roi-hero-explainer {
    font-size: 14px; line-height: 1.5; opacity: 0.95;
    border-right: 2px solid rgba(255,255,255,0.3);
    padding-right: 16px;
}
.org-roi-hero-explainer b { font-size: 18px; }

.org-roi-secondary { gap: 14px; }
.org-roi-card { padding: 18px; }
.org-roi-label   { font-size: 12px; color: var(--text-muted); }
.org-roi-value   { font-size: 32px; font-weight: 700; color: var(--primary, #4129da); margin: 4px 0; }
.org-roi-meta    { font-size: 12px; color: var(--text-muted); }
.org-roi-formula { font-size: 11px; color: var(--text-muted); margin-top: 6px; direction: ltr; text-align: right; }

.org-exp-table { font-size: 13px; }
.org-exp-row-package td { background: rgba(40,167,69,0.05); }
.org-exp-row-ads     td { background: rgba(255,193,7,0.05); }
.org-exp-row-total   td {
    background: var(--bg-secondary, #f8f9fa);
    border-top: 2px solid var(--border, #e5e7eb);
    font-weight: 700;
}

@media print {
    .org-roi-hero { background: #f5f5f5 !important; color: #000 !important; box-shadow: none !important; }
    .org-roi-hero-value { text-shadow: none !important; }
}

/* ── Organic report v2: 3 distinct sections ─────────────────────── */
.org-report-section {
    margin: 36px 0;
    padding-top: 8px;
    border-top: 3px solid var(--border, #e5e7eb);
}
.org-report-section:first-of-type { border-top: none; padding-top: 0; }
.org-report-h2 {
    font-size: 22px; font-weight: 700;
    margin: 0 0 4px;
    display: flex; align-items: center; gap: 10px;
    color: var(--text-primary);
}
.org-report-h2 i { color: var(--primary, #4129da); font-size: 24px; }
.org-report-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 18px; }

/* Paid 2-column report */
.paid-cols-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 14px;
}
.paid-col {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-top: 4px solid;
    border-radius: 10px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.paid-col-header {
    display: flex; align-items: center; gap: 10px;
    font-size: 16px; font-weight: 600;
}
.paid-col-header i { font-size: 22px; }
.paid-col-table { width: 100%; font-size: 13px; }
.paid-col-table td { padding: 8px 4px; border-bottom: 1px solid var(--border-light, #f1f5f9); }
.paid-col-table td:nth-child(1) { color: var(--text-muted); }
.paid-col-table td:nth-child(2) { text-align: left; direction: ltr; }
.paid-col-table td:nth-child(3) { text-align: left; font-size: 11px; color: var(--text-muted); }
.paid-col-roas td { background: var(--bg-secondary, #f8f9fa); font-size: 14px; }
.paid-col-roas td b { font-size: 18px; }
.paid-col-footer {
    text-align: center; font-size: 12px; color: var(--text-muted);
    background: var(--bg-secondary, #f8f9fa);
    padding: 8px; border-radius: 6px;
}

/* Channel summary table with share bars */
.channels-summary-table { font-size: 13px; }
.channels-summary-table th { background: #f8f9fa; }
.channels-summary-table td { padding: 10px 8px; }
.channels-summary-total td {
    background: var(--bg-secondary, #f8f9fa);
    border-top: 2px solid var(--border, #e5e7eb);
    font-size: 14px;
}
.ch-bar-wrap {
    position: relative; height: 18px;
    background: var(--border-light, #f1f5f9);
    border-radius: 4px; overflow: hidden;
    min-width: 180px;
}
.ch-bar {
    position: absolute; top: 0; right: 0; bottom: 0;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.ch-bar-label {
    position: absolute; top: 0; left: 8px;
    line-height: 18px; font-size: 11px; font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 0 3px #fff;
}

@media (max-width: 768px) {
    .paid-cols-grid { grid-template-columns: 1fr; }
}

/* ── Paid disclaimer ─────────────────────────────────────────────── */
.paid-disclaimer {
    margin-top: 14px;
    padding: 16px 18px;
    display: flex; gap: 14px; align-items: flex-start;
    background: rgba(13, 110, 253, 0.05);
    border-right: 4px solid #0d6efd;
}
.paid-disclaimer-icon { color: #0d6efd; font-size: 22px; flex-shrink: 0; line-height: 1; }
.paid-disclaimer p { margin: 6px 0 0; font-size: 13px; line-height: 1.6; color: var(--text-primary); }
.paid-disclaimer code {
    background: rgba(13,110,253,0.1); color: #0d6efd;
    padding: 1px 5px; border-radius: 3px; font-size: 12px;
}

.org-fallback-tag {
    margin-right: 12px;
    font-size: 11px; font-weight: 500;
    background: #fff3cd; color: #856404;
    padding: 4px 8px; border-radius: 4px;
    direction: ltr;
}

/* ── ROI multipliers: 3 cards + 1 summary ─────────────────────────── */
.org-roi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
/* Override older styles when used in the new grid */
.org-roi-grid .org-roi-card {
    padding: 18px;
    text-align: right;
}
.org-roi-grid .org-roi-label   { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.org-roi-grid .org-roi-value   { font-size: 36px; font-weight: 800; line-height: 1.1; }
.org-roi-grid .org-roi-meta    { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.org-roi-grid .org-roi-formula { font-size: 11px; color: var(--text-muted); margin-top: 8px; direction: ltr; text-align: right; }

/* Summary multiplier — gradient block, the headline metric */
.org-roi-summary {
    display: flex; align-items: center;
    gap: 24px; padding: 26px;
    background: linear-gradient(135deg, #4129da 0%, #6b46c1 100%);
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(65,41,218,0.25);
    margin-bottom: 14px;
}
.org-roi-summary-side { flex: 1; min-width: 0; }
.org-roi-summary-main { text-align: center; flex-shrink: 0; }
.org-roi-summary-value {
    font-size: 60px; font-weight: 800; line-height: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.org-roi-summary-label   { font-size: 15px; font-weight: 600; opacity: 0.9; }
.org-roi-summary-formula { font-size: 12px; opacity: 0.7; margin-top: 4px; direction: ltr; text-align: right; }
.org-roi-summary-delta   { font-size: 13px; margin-top: 6px; }
.org-roi-summary-explainer {
    font-size: 14px; line-height: 1.5; opacity: 0.95;
    border-right: 2px solid rgba(255,255,255,0.3);
    padding-right: 16px;
}
.org-roi-summary-explainer b { font-size: 18px; }

@media print {
    .org-roi-summary { background: #f5f5f5 !important; color: #000 !important; box-shadow: none !important; }
    .org-roi-summary-value { text-shadow: none !important; }
}

/* Summary card bottom line: absolute numbers panel */
.org-roi-summary { display: block; padding: 0; }
.org-roi-summary-top {
    display: flex; align-items: center; gap: 24px;
    padding: 26px;
}
.org-roi-bottom {
    background: rgba(0,0,0,0.18);
    padding: 16px 26px;
    border-radius: 0 0 12px 12px;
    display: flex; align-items: center; gap: 24px;
    flex-wrap: wrap;
}
.org-roi-bottom-tag {
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: #fff;
    background: rgba(255,255,255,0.15);
    padding: 4px 12px; border-radius: 4px;
}
.org-roi-bottom-stats {
    display: flex; align-items: center; gap: 28px;
    flex: 1; flex-wrap: wrap; justify-content: center;
}
.org-roi-bottom-stat { text-align: center; min-width: 140px; }
.org-roi-bottom-stat-label {
    font-size: 12px; color: rgba(255,255,255,0.75);
    margin-bottom: 4px;
}
.org-roi-bottom-stat-value {
    font-size: 22px; font-weight: 700; color: #fff;
    direction: ltr;
}
.org-roi-bottom-arrow {
    font-size: 24px; color: rgba(255,255,255,0.6);
}

@media print {
    .org-roi-bottom { background: rgba(0,0,0,0.05) !important; }
    .org-roi-bottom-tag { background: rgba(0,0,0,0.1) !important; color: #000 !important; }
    .org-roi-bottom-stat-label { color: #444 !important; }
    .org-roi-bottom-stat-value { color: #000 !important; }
    .org-roi-bottom-arrow      { color: #888 !important; }
}

/* ROI card bottom — out/in stats per multiplier */
.org-roi-card-bottom {
    display: flex; align-items: center; justify-content: space-around;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light, #f1f5f9);
    text-align: center;
}
.org-roi-card-tag {
    display: inline-block;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    padding: 2px 8px; border-radius: 4px;
    margin-bottom: 4px;
}
.org-roi-card-tag-out { background: #fef2f2; color: #dc3545; }
.org-roi-card-tag-in  { background: #f0fdf4; color: #28a745; }
.org-roi-card-amount {
    font-size: 17px; font-weight: 700; color: var(--text-primary);
    direction: ltr;
}
.org-roi-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.org-roi-card-arrow { font-size: 16px; color: var(--text-muted); flex-shrink: 0; }

/* ── Multipass / IDF redemption section ──────────────────────────── */
.mp-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.mp-tile {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    padding: 16px;
}
.mp-tile-head { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.mp-tile-icon { font-size: 22px; }
.mp-tile-label { font-weight: 600; flex: 1; font-size: 14px; }
.mp-tile-tag {
    font-size: 10px; font-weight: 700;
    padding: 2px 8px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.mp-tile-amount { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; direction:ltr; }
.mp-tile-meta { font-size: 11px; color: var(--text-muted); }

.mp-summary {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 18px 22px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-right: 4px solid #d97706;
    flex-wrap: wrap;
}
.mp-summary-label { font-size: 13px; font-weight: 600; color: #78350f; }
.mp-summary-formula { font-size: 11px; color: #92400e; opacity: 0.8; margin-top: 2px; }
.mp-summary-value {
    font-size: 36px; font-weight: 800;
    color: #78350f;
    direction: ltr;
}
.mp-summary-side {
    flex: 1; min-width: 200px;
    font-size: 13px; color: #78350f;
    line-height: 1.5;
}
.mp-summary-side b { color: #b45309; }

@media print {
    .mp-summary { background: #fff8e6 !important; }
}

/* ── Period Banner Enhancement ───────────────────────────────── */
.org-period-banner { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; }
.org-period-left   { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.org-period-center { display:flex; align-items:center; }

.org-banner-roi { text-align:center; }
.org-banner-roi-val   { font-size:28px; font-weight:800; color:#4129da; line-height:1; }
.org-banner-roi-label { font-size:10px; color:var(--text-muted); margin-top:2px; letter-spacing:.4px; }

/* ── Executive Insights ──────────────────────────────────────── */
.org-insights {
    background:linear-gradient(135deg,#f8f9ff 0%,#f0f4ff 100%);
    border:1px solid #e0e7ff; border-radius:12px;
    padding:16px 20px; margin-bottom:20px;
}
.org-insights-title {
    font-size:12px; font-weight:700; color:#4129da; text-transform:uppercase;
    letter-spacing:.8px; margin-bottom:12px; display:flex; align-items:center; gap:6px;
}
.org-insights-grid {
    display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:10px;
}
.org-insight-item {
    background:#fff; border-radius:8px; padding:10px 14px;
    border-right:3px solid #4129da; display:flex; align-items:flex-start; gap:10px;
    box-shadow:0 1px 4px rgba(0,0,0,.05);
}
.org-insight-icon  { font-size:18px; line-height:1; margin-top:1px; }
.org-insight-title { font-size:12px; font-weight:700; line-height:1.3; }
.org-insight-body  { font-size:11px; color:var(--text-muted); margin-top:2px; line-height:1.4; }

/* ── Derived KPIs row ────────────────────────────────────────── */
.org-derived-row {
    display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; margin-bottom:4px;
}
.org-derived-card {
    display:flex; align-items:center; gap:10px;
    background:#fff; border:1px solid var(--border); border-radius:10px;
    padding:10px 16px; flex:1; min-width:170px;
}
.org-derived-icon {
    width:36px; height:36px; border-radius:8px;
    display:flex; align-items:center; justify-content:center;
    font-size:14px; flex-shrink:0;
}
.org-derived-value { font-size:18px; font-weight:800; color:var(--text); line-height:1.1; }
.org-derived-label { font-size:11px; color:var(--text-muted); margin-top:2px; }

/* ── Failed orders section ───────────────────────────────────── */
.org-failed-summary {
    display:flex; gap:12px; flex-wrap:wrap; margin-bottom:4px;
}
.org-failed-kpi {
    flex:1; min-width:180px;
    background:#fff5f5; border:1px solid #fecaca; border-radius:10px;
    padding:12px 16px; border-right:4px solid #dc3545;
}
.org-failed-kpi-val   { font-size:24px; font-weight:800; color:#dc3545; line-height:1.1; }
.org-failed-kpi-label { font-size:11px; color:#6c757d; margin-top:3px; }
.org-failed-kpi-prev  { font-size:11px; color:#9ca3af; margin-top:4px; }

@media print {
    .org-insights { background:#f8f9ff !important; }
    .org-insight-item { box-shadow:none !important; }
    .org-derived-card { box-shadow:none !important; }
    .org-health-badge { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
