/* ========================================
   Comment Engine — Design System
   ======================================== */

/* ── CSS Variables ── */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary: #8b5cf6;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #3b82f6;
    --info-light: #eff6ff;

    --dark: #111827;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --instagram: #E1306C;
    --instagram-end: #F77737;
    --facebook: #1877F2;

    --bg-body: #f8f9fb;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #6b7280;
    --border: #eaecf0;

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);

    --glow-primary: 0 0 20px rgba(99,102,241,0.15);
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --gradient-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);

    --transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);

    --sidebar-width: 260px;
    --topbar-height: 64px;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
code { background: var(--gray-100); padding: 1px 5px; border-radius: 3px; font-size: 0.8rem; color: var(--primary-hover); }
hr { border: none; }

/* ── App Layout ── */
.app-container { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    color: #e5e7eb;
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-size: 1.1rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius);
    color: var(--gray-400); font-size: 0.875rem; font-weight: 500;
    transition: all 0.15s ease; cursor: pointer;
    margin: 1px 0;
    border-left: 3px solid transparent;
    margin-left: -3px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e5e7eb; border-left-color: rgba(255,255,255,0.15); }
.nav-item.active { background: rgba(99,102,241,0.12); color: #818cf8; border-left-color: #818cf8; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.account-selector { display: flex; flex-direction: column; gap: 6px; }

.selector-label {
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--gray-500);
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    transition: opacity 0.3s ease;
}

/* ── Main Content ── */
.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column; min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    position: sticky; top: 0; z-index: 90;
    background: rgba(255,255,255,0.8);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    height: var(--topbar-height);
    padding: 0 32px;
    display: flex; align-items: center; justify-content: space-between;
}

.page-title { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }

.hamburger {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--text-secondary); padding: 4px;
}
.hamburger svg { width: 24px; height: 24px; }

/* ── Warning Banner ── */
.warning-banner {
    background: var(--warning-light); border-bottom: 1px solid #fde68a;
    padding: 10px 32px; display: flex; align-items: center; gap: 8px;
    font-size: 0.875rem; color: #92400e;
}
.warning-banner svg { flex-shrink: 0; }
.warning-banner a { color: #92400e; font-weight: 600; text-decoration: underline; }

/* ── Section Panels ── */
.content-section { display: none; padding: 28px 32px; max-width: 1400px; }
.content-section.active { display: block; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius); font-size: 0.875rem;
    font-weight: 600; border: none; cursor: pointer;
    transition: all 0.15s ease; white-space: nowrap;
    font-family: inherit; line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: 0 1px 3px rgba(99,102,241,0.3); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(99,102,241,0.35); transform: translateY(-1px); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: rgba(99,102,241,0.06); color: var(--primary); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* ── Connect Buttons (platform-specific) ── */
.connect-ig-btn {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
}
.connect-ig-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.2); }

.connect-fb-btn { background: var(--facebook); color: #fff; }
.connect-fb-btn:hover { background: #1565d8; transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ── Cards ── */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: var(--shadow-sm); transition: var(--transition);
    margin-bottom: 20px;
}
.card:hover { box-shadow: var(--shadow); border-color: rgba(0,0,0,0.08); }

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.card-header h3 { font-size: 0.9rem; font-weight: 700; margin: 0; letter-spacing: 0.01em; }

.card-body { padding: 20px; }

.master-toggle-card { border-left: 4px solid var(--primary); }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }

.stat-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.06); padding: 20px;
    box-shadow: var(--shadow-sm); transition: var(--transition-spring);
    display: flex; align-items: flex-start; gap: 16px;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 44px; height: 44px; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.stat-info { flex: 1; display: flex; flex-direction: column; }
.stat-number { font-size: 1.6rem; font-weight: 800; line-height: 1.2; color: var(--text-primary); letter-spacing: -0.02em; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Charts ── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }

.chart-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border); padding: 20px;
    box-shadow: var(--shadow-sm);
}
.chart-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 16px; }

.chart-bars { display: flex; flex-direction: column; gap: 10px; }

.chart-bar-row { display: flex; align-items: center; gap: 10px; }
.chart-label { width: 90px; flex-shrink: 0; }
.chart-bar-track { flex: 1; height: 22px; background: rgba(0,0,0,0.03); border-radius: 100px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 100px; transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); min-width: 2px; }
.chart-value { width: 40px; font-size: 0.78rem; font-weight: 600; color: var(--text-primary); text-align: right; flex-shrink: 0; }

/* ── Rate Limit Warning ── */
.rate-limit-warning {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 8px;
}
.rate-limit-warning a { color: var(--danger); font-weight: 600; text-decoration: underline; }

/* ── Confirm Modal ── */
.confirm-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease;
}
.confirm-modal {
    background: white; border-radius: 12px; padding: 24px;
    max-width: 400px; width: 90%; box-shadow: var(--shadow-lg);
}
.confirm-modal h3 { margin: 0 0 8px; font-size: 1.1rem; color: var(--text-primary); }
.confirm-modal p { margin: 0 0 20px; font-size: 0.9rem; color: var(--text-secondary); }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-danger {
    background: var(--danger); color: white; border: none;
    padding: 8px 16px; border-radius: 8px; cursor: pointer;
    font-size: 0.85rem; font-weight: 600;
}
.btn-danger:hover { opacity: 0.9; }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; padding: 2px 8px;
    border-radius: 100px; font-size: 0.7rem; font-weight: 600;
    text-transform: capitalize; white-space: nowrap; flex-shrink: 0;
    border: 1px solid transparent; letter-spacing: 0.02em;
}

/* Intent badges */
.badge-intent-spam { background: #fef2f2; color: #dc2626; border-color: rgba(220,38,38,0.15); }
.badge-intent-hate { background: #fef2f2; color: #991b1b; border-color: rgba(153,27,27,0.15); }
.badge-intent-question { background: #eff6ff; color: #2563eb; border-color: rgba(37,99,235,0.15); }
.badge-intent-lead { background: #f0fdf4; color: #16a34a; border-color: rgba(22,163,74,0.15); }
.badge-intent-positive { background: #ecfdf5; color: #059669; border-color: rgba(5,150,105,0.15); }
.badge-intent-negative { background: #fff7ed; color: #ea580c; border-color: rgba(234,88,12,0.15); }
.badge-intent-off_topic { background: #f9fafb; color: #6b7280; border-color: rgba(107,114,128,0.15); }

/* Action badges */
.badge-action-reply { background: #eff6ff; color: #2563eb; border-color: rgba(37,99,235,0.15); }
.badge-action-hide { background: #fef2f2; color: #dc2626; border-color: rgba(220,38,38,0.15); }
.badge-action-delete { background: #fef2f2; color: #991b1b; border-color: rgba(153,27,27,0.15); }
.badge-action-like { background: #fdf4ff; color: #c026d3; border-color: rgba(192,38,211,0.15); }
.badge-action-dm_private_reply { background: #f0fdf4; color: #16a34a; border-color: rgba(22,163,74,0.15); }
.badge-action-dm { background: #f0fdf4; color: #16a34a; border-color: rgba(22,163,74,0.15); }
.badge-action-dm_and_reply { background: #f0fdf4; color: #16a34a; border-color: rgba(22,163,74,0.15); }
.badge-action-ignore { background: #f9fafb; color: #6b7280; border-color: rgba(107,114,128,0.15); }

/* Status badges */
.badge-status-received { background: #f9fafb; color: #6b7280; border-color: rgba(107,114,128,0.15); }
.badge-status-actioned { background: #ecfdf5; color: #059669; border-color: rgba(5,150,105,0.15); }
.badge-status-error { background: #fef2f2; color: #dc2626; border-color: rgba(220,38,38,0.15); }
.badge-status-rate_limited { background: #fffbeb; color: #d97706; border-color: rgba(217,119,6,0.15); }

/* Platform badges */
.badge-platform-instagram { background: linear-gradient(45deg, #f09433, #dc2743); color: #fff; }
.badge-platform-facebook { background: var(--facebook); color: #fff; }

/* ── Account Cards ── */
.accounts-grid { display: flex; flex-direction: column; gap: 24px; }

.accounts-group { margin-bottom: 0; }
.accounts-group-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.9rem; font-weight: 700; color: var(--gray-700);
    padding: 8px 4px; margin-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}
.accounts-group-count {
    font-weight: 400; font-size: 0.78rem; color: var(--gray-400);
    margin-left: auto;
}
.accounts-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.account-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1.5px solid rgba(0,0,0,0.06); padding: 20px;
    box-shadow: var(--shadow-sm); transition: var(--transition-spring);
}
.account-card:hover { box-shadow: var(--shadow-md); border-color: rgba(0,0,0,0.1); transform: translateY(-2px); }
.account-card-selected { border-color: var(--primary); box-shadow: var(--glow-primary); background: var(--primary-light); }
.account-card-selected:hover { border-color: var(--primary-hover); }

.account-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.account-name { font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.account-id { font-size: 0.78rem; color: var(--text-muted); }
.account-expiry { font-size: 0.72rem; color: var(--gray-400); margin-top: 2px; }
.account-expiry-warning { color: var(--warning); font-weight: 600; }
.account-expiry-danger { color: var(--danger); font-weight: 600; }

.account-card-actions {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 14px; margin-top: 14px;
    border-top: 1px solid var(--gray-100);
}

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-group { margin-bottom: 0; }
.form-label {
    display: block; font-size: 0.84rem; font-weight: 600;
    color: var(--text-primary); margin-bottom: 6px;
}

.form-input, .form-textarea, .form-select {
    width: 100%; padding: 9px 12px; border-radius: var(--radius);
    border: 1px solid rgba(0,0,0,0.1); font-size: 0.875rem;
    font-family: inherit; color: var(--text-primary);
    background: #fafbfc; transition: all 0.15s ease;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
    background: #fff;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 36px;
}

.form-select-sm {
    width: 100%; padding: 8px 10px; border-radius: var(--radius);
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    color: #e5e7eb; font-size: 0.8rem; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
    font-family: inherit;
}
.form-select-sm option { background: var(--dark); color: #e5e7eb; }

/* ── Range Slider ── */
.form-range {
    width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
    background: var(--gray-200); border-radius: 3px; outline: none;
    margin-top: 8px;
}
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px;
    border-radius: 50%; background: var(--gradient-primary); cursor: pointer;
    box-shadow: 0 1px 4px rgba(99,102,241,0.3); transition: var(--transition);
}
.form-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.form-range::-moz-range-thumb {
    width: 18px; height: 18px; border: none;
    border-radius: 50%; background: var(--gradient-primary); cursor: pointer;
    box-shadow: 0 1px 4px rgba(99,102,241,0.3);
}

.slider-value {
    font-weight: 700; color: var(--primary);
}

/* ── Toggle Switch ── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #d1d5db; border-radius: 100px; transition: var(--transition);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
.toggle-slider::before {
    content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
    transition: var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--gradient-primary); box-shadow: inset 0 1px 2px rgba(0,0,0,0.06), var(--glow-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.toggle-lg { width: 56px; height: 30px; }
.toggle-lg .toggle-slider::before { height: 24px; width: 24px; }
.toggle-lg input:checked + .toggle-slider::before { transform: translateX(26px); }

/* ── Toggle Rows ── */
.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0;
}
.toggle-row strong { font-size: 0.875rem; }
.toggle-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Content Containers ── */
.dashboard-content,
.settings-content,
.keywords-content,
.activity-content { }

/* ── Empty State ── */
.empty-state {
    text-align: center; padding: 64px 40px;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 20px; animation: float-gentle 3s ease-in-out infinite; }
.empty-state h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { color: var(--text-secondary); font-size: 0.95rem; max-width: 400px; margin: 0 auto 24px; }

/* ── Loading / Skeleton ── */
.loading-skeleton { padding: 16px 0; }
.skeleton-row {
    height: 16px; margin-bottom: 12px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}
.skeleton-row:nth-child(2) { width: 80%; }
.skeleton-row:nth-child(3) { width: 60%; }

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Recent Activity Items ── */
.activity-item {
    padding: 12px 0; border-bottom: 1px solid var(--gray-100);
}
.activity-item:last-child { border-bottom: none; }

.activity-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.activity-item-header strong { font-size: 0.84rem; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); }
.activity-text { font-size: 0.84rem; color: var(--text-secondary); margin-bottom: 6px; }
.activity-badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ── Data Table ── */
.data-table-wrapper {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border); overflow-x: auto;
    box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; padding: 10px 16px; font-size: 0.75rem;
    font-weight: 600; color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 0.03em; background: var(--gray-50);
    border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 16px; font-size: 0.84rem; border-bottom: 1px solid var(--gray-100); }
.data-table tr:last-child td { border-bottom: none; }

.expandable-row { cursor: pointer; transition: var(--transition); }
.expandable-row:hover td { background: var(--gray-50); }

.comment-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }

.detail-row td { padding: 0 !important; }
.detail-content {
    padding: 16px 20px; background: var(--gray-50);
    border-bottom: 2px solid var(--border); font-size: 0.84rem;
}
.detail-field { margin-bottom: 6px; }
.detail-field strong { color: var(--text-secondary); font-size: 0.78rem; }
.reply-field { background: var(--info-light); padding: 8px 12px; border-radius: var(--radius); border-left: 3px solid var(--info); margin: 8px 0; }
.dm-field { background: var(--success-light); padding: 8px 12px; border-radius: var(--radius); border-left: 3px solid var(--success); margin: 8px 0; }
.manual-reply-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200); }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 0; }
.pagination-info { font-size: 0.84rem; color: var(--text-secondary); }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: var(--shadow-lg); width: 90%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }

.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.5rem; color: var(--text-muted); padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }

/* ── Wizard Steps ── */
.wizard-steps {
    display: flex; align-items: center; justify-content: center;
    gap: 32px; margin-bottom: 24px;
}
.wizard-step {
    display: flex; align-items: center; gap: 8px;
    color: var(--gray-400); font-size: 0.84rem; font-weight: 500;
}
.wizard-step.active { color: var(--primary); }
.wizard-step.active .step-number { background: var(--primary); color: #fff; }
.wizard-step.completed { color: var(--success); }
.wizard-step.completed .step-number { background: var(--success); color: #fff; }

.step-number {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--gray-200); color: var(--gray-500);
    font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
}

/* ── Wizard Panels ── */
.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

/* ── Platform Cards ── */
.platform-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.platform-card {
    padding: 28px 20px; border-radius: var(--radius-lg);
    border: 2px solid var(--border); text-align: center;
    cursor: pointer; transition: var(--transition);
    background: none; font-family: inherit; color: var(--text-primary);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.platform-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }

.platform-icon {
    width: 56px; height: 56px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 4px;
}
.ig-icon { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.fb-icon { background: var(--facebook); }

.platform-desc { font-size: 0.78rem; color: var(--text-muted); }

/* ── Setup Instructions ── */
.setup-instructions { display: flex; flex-direction: column; gap: 10px; }

.instruction-step {
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 0.875rem; color: var(--text-secondary);
}

.instruction-num {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
    margin-top: 1px;
}

.instruction-step a { color: var(--primary); font-weight: 600; }

/* ── Success Check ── */
.success-check {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--success-light); display: flex;
    align-items: center; justify-content: center;
    margin: 0 auto;
    animation: scaleIn 0.3s ease;
}
@keyframes scaleIn { from { transform: scale(0); } to { transform: scale(1); } }

/* ── Keyword Trigger Cards ── */
.trigger-card {
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 14px 16px;
    margin-bottom: 10px;
    transition: var(--transition);
}
.trigger-card:hover { box-shadow: var(--shadow); }

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

.trigger-keyword { font-weight: 700; font-size: 0.9rem; }

.trigger-template {
    font-size: 0.78rem; color: var(--text-muted); margin-top: 8px;
    padding-top: 8px; border-top: 1px solid var(--gray-100);
}

/* ── Toast ── */
.toast-container {
    position: fixed; bottom: 90px; right: 20px;
    display: flex; flex-direction: column-reverse; gap: 8px;
    z-index: 300; pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 12px 16px; border-radius: var(--radius-lg);
    font-size: 0.84rem; font-weight: 500;
    box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
    max-width: 360px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    backdrop-filter: blur(8px);
}
.toast.show { transform: translateX(0); }

.toast-success { background: rgba(6,95,70,0.95); color: #fff; }
.toast-error { background: rgba(153,27,27,0.95); color: #fff; }
.toast-warning { background: rgba(146,64,14,0.95); color: #fff; }
.toast-info { background: rgba(30,64,175,0.95); color: #fff; }

.toast-icon { flex-shrink: 0; display: flex; }
.toast-message { flex: 1; }

/* ── Focus Styles ── */
.btn:focus-visible,
.nav-item:focus-visible,
.support-fab:focus-visible,
.range-btn:focus-visible,
.support-tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible,
.form-select-sm:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.toggle input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px var(--primary-light);
}

.modal-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

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

/* ── Spinner ── */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.7s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Setup Wizard ── */
.setup-wizard { max-width: 680px; }

.setup-progress { margin-bottom: 28px; }

.setup-progress-steps {
    display: flex; align-items: center; justify-content: space-between;
    gap: 4px; padding: 16px 20px;
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}

.setup-step {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.78rem; font-weight: 500; color: var(--gray-400);
    white-space: nowrap;
}
.setup-step.active { color: var(--primary); }
.setup-step.active .setup-step-num { background: var(--primary); color: #fff; }
.setup-step.completed { color: var(--success); }
.setup-step.completed .setup-step-num { background: var(--success); color: #fff; }

.setup-step-num {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--gray-200); color: var(--gray-500);
    font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}

.setup-panel { display: none; }
.setup-panel.active { display: block; }

/* Setup nav indicator dot */
.setup-indicator {
    width: 8px; height: 8px; border-radius: 50%;
    margin-left: auto; flex-shrink: 0;
}
.setup-indicator.setup-pending { background: var(--danger); }
.setup-indicator.setup-done { background: var(--success); }

/* ── Mode Toggle Grid (Moderate / Engage cards) ── */
.mode-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger { display: flex; }
    .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .content-section { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .accounts-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-input, .filter-bar .form-select { max-width: 100%; }
    .platform-cards { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .setup-progress-steps { flex-wrap: wrap; gap: 8px; }
    .setup-step span:not(.setup-step-num) { display: none; }
    .metrics-triggers-row { grid-template-columns: 1fr; }
    .plans-grid { grid-template-columns: 1fr; }
    .mode-toggles { grid-template-columns: 1fr; }
    .wizard-steps { gap: 16px; }
    .chart-label { width: 70px; font-size: 0.72rem; }
    .chart-value { width: 32px; font-size: 0.72rem; }
    .comment-cell { max-width: 200px; }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px; }
    .empty-state { padding: 48px 20px; }
    .warning-banner { padding: 10px 16px; }
    .toggle-row { gap: 12px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .content-section { padding: 12px; }
    .topbar { padding: 0 12px; height: 56px; }
    .page-title { font-size: 1.05rem; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-number { font-size: 1.4rem; }
    .stat-icon { width: 36px; height: 36px; }
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }
    .chart-label { width: 56px; font-size: 0.68rem; }
    .wizard-steps { gap: 8px; }
    .step-number { width: 24px; height: 24px; font-size: 0.7rem; }
    .platform-cards { grid-template-columns: 1fr; }
    .platform-card { padding: 20px 16px; }
    .platform-icon { width: 44px; height: 44px; }
    .modal { width: 95%; }
    .modal-body { padding: 14px; }
    .modal-header { padding: 14px 16px; }
    .confirm-modal { width: 95%; padding: 20px; }
    .range-btn { padding: 5px 10px; font-size: 0.72rem; }
    .accounts-group-grid { grid-template-columns: 1fr; }
    .empty-state { padding: 40px 16px; }
    .empty-state p { font-size: 0.875rem; }
    .pagination { gap: 8px; flex-wrap: wrap; }
    .filter-bar { gap: 8px; }
    .support-fab { bottom: 16px; right: 16px; width: 48px; height: 48px; }
    .support-fab svg { width: 20px; height: 20px; }
}

/* ── Dashboard Enhancements ── */
.dashboard-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}
.time-range-selector {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    overflow: hidden;
}
.range-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    border-right: 1px solid var(--border);
    border-radius: 0;
}
.range-btn:last-child { border-right: none; }
.range-btn:hover { background: var(--gray-50); color: var(--gray-700); }
.range-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 1px 4px rgba(99,102,241,0.25);
}

.metrics-triggers-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.metrics-triggers-row .card { margin-bottom: 0; }

.automation-health-card {
    border-left: 4px solid var(--gray-300);
}

/* ── Support FAB ── */
.support-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    z-index: 1000;
    transition: transform 0.15s, box-shadow 0.15s;
}
.support-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}
.fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* ── Notification badges ── */
.notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}
.notification-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    margin-left: 6px;
    vertical-align: middle;
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.support-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-100);
    margin-bottom: 16px;
}
.support-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--gray-400);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.support-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.support-tab-panel {
    display: none;
}
.support-tab-panel.active {
    display: block;
}
.ticket-card {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.ticket-card .ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

/* ── Impersonation Banner ── */
.impersonation-banner {
    background: var(--warning);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 0.88rem;
    font-weight: 500;
    color: white;
}
.impersonation-banner .btn {
    background: rgba(255,255,255,0.25);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    font-weight: 600;
}
.impersonation-banner .btn:hover {
    background: rgba(255,255,255,0.4);
}

/* ── Admin Section ── */
.admin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.admin-user-row:hover td {
    background: var(--gray-50);
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-100);
    margin-bottom: 20px;
}
.admin-tab {
    flex: none;
    padding: 10px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--gray-400);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--gray-600); }
.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }

/* User detail modal */
.user-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.user-detail-field { padding: 8px 0; }
.user-detail-field label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gray-400);
    display: block;
    margin-bottom: 2px;
}
.user-detail-field span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}
.user-detail-field .form-input,
.user-detail-field .form-select {
    margin-top: 4px;
    font-size: 0.88rem;
}

/* User detail sub-tabs */
.user-detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-100);
    margin-bottom: 16px;
    gap: 0;
}
.user-detail-tab {
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gray-400);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.user-detail-tab:hover { color: var(--text-primary); }
.user-detail-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ── Billing Section ── */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-top: 20px;
}
@media (max-width: 1100px) {
    .plans-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
    .plans-grid { grid-template-columns: 1fr; }
}
.plan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}
.plan-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.plan-card .plan-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.plan-card .plan-price {
    margin: 8px 0 12px;
    line-height: 1;
}
.plan-card .plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    text-align: left;
    flex: 1;
}
.plan-card .plan-features li {
    padding: 5px 0;
    font-size: 0.78rem;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-50);
}
.plan-card .plan-features li:last-child { border-bottom: none; }
.plan-card .plan-features li::before {
    content: '\2713';
    color: var(--success);
    font-weight: 700;
    margin-right: 6px;
    font-size: 0.72rem;
}
.plan-card-current {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.plan-card-popular {
    border-color: var(--secondary);
    position: relative;
}
.plan-card-popular:hover {
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.12);
}
.plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    color: white;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.plan-price-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
}
.plan-price-period {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--gray-400);
}
.plan-btn {
    width: 100%;
    margin-top: auto;
    font-size: 0.82rem;
    padding: 8px 12px;
}
.plan-card-enterprise {
    border-color: var(--gray-200);
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(99, 102, 241, 0.03) 100%);
}
.current-plan-card {
    border-left: 4px solid var(--primary);
}
.billing-content {
    max-width: 100%;
}

/* ── Preset Pills ── */
.preset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.preset-pill {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    background: transparent;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.preset-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99,102,241,0.04);
}
.preset-pill.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: 0 1px 4px rgba(99,102,241,0.3);
}

/* ── Onboarding ── */
.onboarding-step {
    transition: var(--transition);
}
.onboarding-step:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}
.onboarding-step.completed {
    opacity: 0.6;
}
.onboarding-step.completed .onboarding-step-icon {
    background: var(--success);
    color: white;
}
.onboarding-step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.9rem;
}

/* ── Float Animation ── */
@keyframes float-gentle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
