:root {
    --primary-color: #8a2123;
    --bs-primary-rgb: 138, 33, 35;
    --primary-hover: #6a1618;
    --secondary-color: #d9a01c;
    --secondary-hover: #b8860b;
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: rgba(226, 232, 240, 0.85);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --gradient-primary: linear-gradient(135deg, #8a2123 0%, #6a1618 100%);
    --gradient-gold: linear-gradient(135deg, #fcd34d 0%, #d9a01c 100%);
    --gradient-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    
    --shadow-sm: 0 2px 4px rgba(138, 33, 35, 0.04);
    --shadow-md: 0 8px 20px rgba(138, 33, 35, 0.07);
    --shadow-lg: 0 15px 35px -5px rgba(138, 33, 35, 0.12);
    --shadow-glow: 0 0 20px rgba(217, 160, 28, 0.25);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color) !important;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Background Animated Blobs */
.bg-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 0;
    opacity: 0.35;
    animation: float 20s infinite ease-in-out alternate;
    pointer-events: none;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(217, 160, 28, 0.4) 0%, rgba(217, 160, 28, 0) 70%);
    top: -200px;
    left: -100px;
}

.blob-2 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(138, 33, 35, 0.3) 0%, rgba(138, 33, 35, 0) 70%);
    bottom: -300px;
    right: -200px;
    animation-delay: -5s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0) 70%);
    top: 40%;
    left: 30%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(50px, 30px) scale(1.1); }
    100% { transform: translate(-30px, -50px) scale(0.9); }
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Main Layout */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem 1rem;
}

/* Modern Navbar / Header */
.autob-navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.85rem 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.75rem;
}

.brand-icon-box {
    width: 44px;
    height: 44px;
    background: var(--gradient-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fcd34d;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(138, 33, 35, 0.25);
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.1;
}

.brand-tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Navigation Tabs */
.nav-pills-custom {
    gap: 8px;
}
.nav-pills-custom .nav-link {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.55rem 1.15rem;
    border-radius: 12px;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}
.nav-pills-custom .nav-link:hover {
    color: var(--primary-color);
    background: rgba(138, 33, 35, 0.05);
}
.nav-pills-custom .nav-link.active {
    background: var(--gradient-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(138, 33, 35, 0.25);
}

/* Glass Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

.glass-card-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* Stat Cards */
.stat-card {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}
.stat-card.gold::after {
    background: var(--secondary-color);
}
.stat-card.green::after {
    background: var(--success);
}
.stat-card.blue::after {
    background: var(--info);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.stat-icon.primary {
    background: rgba(138, 33, 35, 0.1);
    color: var(--primary-color);
}
.stat-icon.gold {
    background: rgba(217, 160, 28, 0.15);
    color: #b8860b;
}
.stat-icon.green {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}
.stat-icon.blue {
    background: rgba(59, 130, 246, 0.12);
    color: var(--info);
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}
.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Custom Buttons */
.btn-primary {
    background: var(--gradient-primary) !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 600;
    border-radius: 12px;
    padding: 0.6rem 1.4rem;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(138, 33, 35, 0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #6a1618 0%, #4a0c0e 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(138, 33, 35, 0.3);
}

.btn-gold {
    background: var(--gradient-gold) !important;
    border: none !important;
    color: #451a03 !important;
    font-weight: 700;
    border-radius: 12px;
    padding: 0.6rem 1.4rem;
    box-shadow: 0 4px 12px rgba(217, 160, 28, 0.25);
}
.btn-gold:hover {
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%) !important;
    transform: translateY(-1px);
}

.btn-outline-custom {
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    border-radius: 12px;
    font-weight: 600;
    padding: 0.55rem 1.2rem;
    transition: all 0.2s;
}
.btn-outline-custom:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--primary-color);
}

/* Bot Task Cards */
.task-card {
    border-left: 4px solid var(--primary-color);
    transition: all 0.25s ease;
}
.task-card.inactive {
    border-left-color: #94a3b8;
    opacity: 0.85;
}

/* Status Badges */
.badge-status {
    padding: 0.35rem 0.75rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.badge-status.active {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.badge-status.paused {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}
.badge-status.success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #6ee7b7;
}
.badge-status.failed {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.badge-status.ai {
    background: #fdf4ff;
    color: #86198f;
    border: 1px solid #f0abfc;
}

/* Dynamic Field Creator Row */
.field-row {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.6rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Code & JSON Previewer */
.json-viewer {
    background: #0f172a;
    color: #38bdf8;
    font-family: "Fira Code", monospace;
    font-size: 0.85rem;
    padding: 1.25rem;
    border-radius: 14px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #1e293b;
}

/* Form Inputs */
.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(138, 33, 35, 0.12);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Refresh Spin Animation */
@keyframes spinRefresh {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-refreshing .fa-rotate {
    animation: spinRefresh 0.6s ease-in-out;
}

/* ── Alert Rules UI ── */
.alert-rule-row {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    animation: fadeIn 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

/* ── Change Detection Badges & Status Pills ── */
.badge-change-up {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.badge-change-down {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.badge-change-text {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.badge-change-none {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 20px;
}

/* ── Analytics KPI Cards ── */
.analytics-kpi-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    transition: transform 0.2s ease;
}
.analytics-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
.analytics-kpi-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.analytics-kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin-top: 0.3rem;
}

/* ── Change History Timeline ── */
.timeline-item {
    position: relative;
    padding-left: 1.75rem;
    padding-bottom: 1.25rem;
    border-left: 2px solid #e2e8f0;
}
.timeline-item:last-child {
    border-left: 2px solid transparent;
    padding-bottom: 0;
}
.timeline-dot {
    position: absolute;
    left: -7px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px rgba(138, 33, 35, 0.2);
}
.timeline-dot.up {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.timeline-dot.down {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}
.timeline-dot.neutral {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

