/* ============================================
   ScrapMaster - Pastel Garden Aesthetic
   A soft, refined interface with organic flow
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Outfit:wght@300;400;500;600;700&display=swap');

/* CSS Variables - Pastel Garden Palette */
:root {
    /* Primary Pastels */
    --color-lavender: #E6D5F5;
    --color-mint: #D5F5E3;
    --color-peach: #FFE5D9;
    --color-sky: #D5E8F5;
    --color-rose: #FFD5E5;
    
    /* Accent Colors */
    --color-sage: #A8C9B8;
    --color-lilac: #C8B6D9;
    --color-coral: #FFB8A3;
    --color-periwinkle: #A3C4FF;
    
    /* Neutrals */
    --color-cream: #FFF9F5;
    --color-charcoal: #4A4A4A;
    --color-slate: #6B7280;
    --color-white: #FFFFFF;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #E6D5F5 0%, #D5E8F5 100%);
    --gradient-warm: linear-gradient(135deg, #FFE5D9 0%, #FFD5E5 100%);
    --gradient-cool: linear-gradient(135deg, #D5F5E3 0%, #D5E8F5 100%);
    --gradient-sunset: linear-gradient(135deg, #FFD5E5 0%, #FFE5D9 50%, #E6D5F5 100%);
    
    /* Typography */
    --font-display: 'DM Serif Display', Georgia, serif;
    --font-body: 'Outfit', -apple-system, sans-serif;
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
    
    /* Shadows - Soft & Organic */
    --shadow-sm: 0 2px 8px rgba(138, 135, 165, 0.08);
    --shadow-md: 0 4px 16px rgba(138, 135, 165, 0.12);
    --shadow-lg: 0 8px 32px rgba(138, 135, 165, 0.16);
    --shadow-xl: 0 16px 48px rgba(138, 135, 165, 0.2);
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;
}

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    background: var(--gradient-sunset);
    background-attachment: fixed;
    min-height: 100vh;
    padding: var(--space-lg);
    color: var(--color-charcoal);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Subtle grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--color-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    backdrop-filter: blur(20px);
    animation: containerFadeIn 0.6s ease-out;
}

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

/* Header */
header {
    /* background: var(--gradient-primary); */
    background: #ececec;
    color: var(--color-charcoal);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Decorative header pattern */
/* header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: headerFloat 8s ease-in-out infinite;
} */

/* header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    animation: headerFloat 6s ease-in-out infinite reverse;
} */

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

header h1 {
    font-family: var(--font-display);
    font-size: 3.5em;
    font-weight: 400;
    margin-bottom: var(--space-sm);
    position: relative;
    letter-spacing: -0.02em;
    animation: titleSlide 0.8s ease-out 0.2s both;
}

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

header p {
    font-size: 1.1em;
    opacity: 0.8;
    font-weight: 300;
    position: relative;
    animation: titleSlide 0.8s ease-out 0.4s both;
}

/* Navigation */
nav {
    display: flex;
    background: var(--color-cream);
    padding: var(--space-sm);
    gap: var(--space-xs);
    overflow-x: auto;
    scrollbar-width: none;
}

nav::-webkit-scrollbar {
    display: none;
}

.nav-btn {
    flex: 1;
    min-width: 210px;
    padding: var(--space-md) var(--space-lg);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    font-family: var(--font-body);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: var(--radius-md);
    position: relative;
    color: var(--color-slate);
    white-space: nowrap;
}

.nav-btn::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--gradient-primary);
    transform: translateX(-50%);
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: var(--radius-full);
}

.nav-btn:hover {
    transform: translateY(-2px);
    color: var(--color-charcoal);
}

.nav-btn:hover::before {
    width: 60%;
}

.nav-btn.active {
    background: var(--gradient-warm);
    color: var(--color-charcoal);
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.nav-btn.active::before {
    width: 80%;
}

/* Pages */
.page {
    display: none;
    padding: var(--space-xl);
    min-height: 500px;
}

.page.active {
    display: block;
    animation: pageSlide 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pageSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

h2 {
    font-family: var(--font-display);
    font-size: 2.5em;
    font-weight: 400;
    color: var(--color-charcoal);
    margin-bottom: var(--space-lg);
    letter-spacing: -0.01em;
    position: relative;
    display: inline-block;
}

h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--gradient-warm);
    border-radius: var(--radius-full);
}

body.redesign h2 {
    margin-bottom: 22px;
}

h3 {
    font-family: var(--font-body);
    font-size: 1.4em;
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: var(--space-md);
    text-transform: capitalize;
}

h4 {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: var(--space-sm);
}

h5 {
    font-size: 1em;
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: var(--space-sm);
}

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

.stat-card {
    background: var(--gradient-cool);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transition: all 0.6s ease;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    top: -20%;
    right: -20%;
}

.stat-card:nth-child(1) { background: var(--gradient-cool); animation-delay: 0s; }
.stat-card:nth-child(2) { background: var(--gradient-warm); animation-delay: 0.1s; }
.stat-card:nth-child(3) { background: var(--gradient-primary); animation-delay: 0.2s; }
.stat-card:nth-child(4) { background: linear-gradient(135deg, #FFD5E5 0%, #C8B6D9 100%); animation-delay: 0.3s; }

.stat-card h3 {
    font-size: 0.9em;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-number {
    font-family: var(--font-display);
    font-size: 2em;
    font-weight: 400;
    color: var(--color-charcoal);
    line-height: 1;
}
p#system-status {
    font-size: 1.5rem;
}
/* Section */
.section {
    background: var(--color-cream);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    border: 1px solid var(--color-lavender);
}

/* Buttons */
.btn-primary {
    padding: var(--space-md) var(--space-lg);
    background: var(--gradient-primary);
    color: var(--color-charcoal);
    border: none;
    border-radius: var(--radius-full);
    font-size: 1em;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

body.redesign .btn-small {
    border: 1px solid #DDD7E5;
    border-radius: 7px;
    padding: 8px 13px;
    font-size: 0.85em;
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.redesign .btn-small:hover {
    transform: none;
    background: var(--color-cream);
    border-color: var(--color-lilac);
}

body.redesign .btn-icon {
    display: inline-flex;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

body.redesign .btn-icon svg {
    width: 100%;
    height: 100%;
}

.batch-title-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.batch-owner-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    padding: 4px 11px;
    background: #F3F1F7;
    color: var(--color-slate);
    border-radius: 6px;
    font-size: 0.72em;
    font-weight: 600;
    text-transform: capitalize;
}

.batch-owner-pill svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.batch-scrapy-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #EEF2FF;
    color: #4338CA;
    border: 1px solid #C7D2FE;
    border-radius: 10px;
    font-size: 0.62em;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.batch-scrapy-pill svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.batch-rename-btn {
    background: none;
    border: none;
    color: #B0AAB8;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    padding: 5px 6px;
    border-radius: 5px;
    transition: background-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
}

.batch-rename-btn svg {
    width: 13px;
    height: 13px;
}

.batch-rename-btn:hover {
    background: #F3F1F7;
    color: var(--color-charcoal);
}

.batch-overflow-wrap {
    position: relative;
    display: inline-block;
}

.btn-overflow-toggle {
    padding: 8px 12px !important;
    font-size: 1.1em !important;
    line-height: 1;
    font-weight: 700;
}

.batch-overflow-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--color-white);
    border: 1px solid #E0D9EC;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(89, 70, 122, 0.14), 0 2px 6px rgba(89, 70, 122, 0.08);
    min-width: 210px;
    z-index: 9000;
    padding: 6px;
    flex-direction: column;
}

.batch-overflow-menu.open {
    display: flex;
}

.batch-overflow-menu button {
    background: none;
    border: none;
    text-align: left;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 0.88em;
    font-family: var(--font-body);
    color: var(--color-charcoal);
    cursor: pointer;
    transition: background-color 0.12s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 9px;
}

.overflow-icon {
    display: inline-flex;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}

.overflow-icon svg {
    width: 100%;
    height: 100%;
}

.subbatch-card {
    background: var(--color-cream);
    border: 1px solid #ECE2DC;
    border-radius: 10px;
    padding: 14px;
}

.subbatch-name {
    font-weight: 600;
    color: #374151;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.subbatch-rename-btn {
    color: #B5A89E;
}

.subbatch-rename-btn:hover {
    background: #EFE6DD;
    color: #374151;
}

body.redesign .subbatch-card .btn-small {
    background: var(--color-white);
    font-size: 0.82em;
    padding: 7px 11px;
}

.btn-accent-indigo {
    background: #EEF2FF !important;
    color: #4338CA !important;
    border-color: #C7D2FE !important;
}

.btn-accent-indigo:hover {
    background: #E0E7FF !important;
}

.btn-accent-dark {
    background: #1A1D24 !important;
    color: #93C5FD !important;
    border-color: #1A1D24 !important;
}

.btn-accent-dark:hover {
    background: #252932 !important;
}

.batch-overflow-menu button:hover {
    background: var(--color-cream);
}

.batch-overflow-divider {
    height: 1px;
    background: #ECE7F0;
    margin: 5px 4px;
}

.batch-overflow-danger {
    color: #B91C3C !important;
}

.batch-overflow-danger:hover {
    background: #FEF0F2 !important;
}

body.redesign .btn-primary {
    border-radius: 8px;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    padding: 13px 26px;
    border: 1px solid rgba(89, 70, 122, 0.12);
}

body.redesign .btn-primary::before {
    display: none;
}

body.redesign .btn-primary:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(20, 16, 30, 0.08);
}

.btn-small {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-white);
    color: var(--color-charcoal);
    border: 2px solid var(--color-lavender);
    border-radius: var(--radius-full);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-body);
}

.btn-small:hover {
    background: var(--color-lavender);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-mini {
    padding: 0.5rem 1rem;
    background: var(--color-mint);
    color: var(--color-charcoal);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-body);
}

.btn-mini:hover {
    background: var(--color-sage);
    transform: scale(1.05);
}

.btn-danger {
    background: linear-gradient(135deg, #FFB8A3 0%, #FFD5E5 100%);
    border-color: transparent;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #FF9580 0%, #FFB8C8 100%);
}

body.redesign .btn-danger {
    background: #FDEEEE;
    color: #B91C3C;
    border-color: #F5D5D5;
}

body.redesign .btn-danger:hover {
    background: #FBE0E0;
    border-color: #F0B8B8;
}

.view-all-outputs-banner {
    display: flex;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--color-cream);
    border-radius: 8px;
    border: 1px solid #ECE7F0;
}

/* Batch Cards */
.batch-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-md);
    border: 2px solid var(--color-cream);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    /* transform: translateX(4px); */
    box-shadow: var(--shadow-lg);
    border-color: var(--color-lavender);
}

.batch-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-primary);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.batch-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-lavender);
}

.batch-card:hover::before {
    transform: scaleY(1);
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.batch-header h3 {
    font-family: var(--font-display);
    font-size: 1.6em;
    font-weight: 400;
    color: var(--color-charcoal);
}

.batch-info {
    margin-bottom: var(--space-md);
}

.batch-info p {
    color: var(--color-slate);
    font-size: 0.95em;
    margin-bottom: var(--space-xs);
}

.badge {
    padding: 0.4rem 1rem;
    background: var(--gradient-warm);
    color: var(--color-charcoal);
    border-radius: var(--radius-full);
    font-size: 0.85em;
    font-weight: 600;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.badge-active {
    background: linear-gradient(135deg, #D5F5E3 0%, #A8C9B8 100%);
    color: #166534;
    font-family: var(--font-mono, monospace);
    font-size: 0.8em;
    animation: livePulse 2s ease-in-out infinite;
}

.batch-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.batch-files {
    margin-top: var(--space-md);
}

/* File Items */
.file-item {
    background: var(--color-cream);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.file-item:hover {
    border-color: var(--color-lavender);
    background: var(--color-white);
    box-shadow: var(--shadow-sm);
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.file-header strong {
    font-weight: 600;
    color: var(--color-charcoal);
}

.file-details {
    margin-bottom: var(--space-sm);
}

.file-details p {
    font-size: 0.9em;
    color: var(--color-slate);
    margin-bottom: var(--space-xs);
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.warning {
    color: #FF6B35;
    font-size: 0.85em;
    background: var(--color-peach);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* Status Badges */
.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.pending {
    background: var(--color-sky);
    color: #0077B6;
}

.status-badge.queued {
    background: #FFF3CD;
    color: #92400E;
    animation: pulse 2s ease-in-out infinite;
}

.status-badge.running {
    background: var(--color-peach);
    color: #FF6B35;
    animation: pulse 2s ease-in-out infinite;
}

.status-badge.done,
.status-badge.completed {
    background: var(--color-mint);
    color: #2D6A4F;
}

.status-badge.error {
    background: var(--color-rose);
    color: #C1121F;
}

.status-badge.stopped {
    background: var(--color-slate);
    color: var(--color-white);
}

.status-badge.active {
    background: var(--color-mint);
    color: #2D6A4F;
}

.status-badge.paused {
    background: var(--color-sky);
    color: #0077B6;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Loading States */
.loading {
    text-align: center;
    padding: var(--space-xl);
    color: var(--color-slate);
    font-style: italic;
}

.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: var(--space-md) auto 0;
    border: 4px solid var(--color-lavender);
    border-top-color: var(--color-lilac);
    border-radius: 50%;
    animation: spinner 1s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

.loading-mini {
    color: var(--color-slate);
    font-size: 0.85em;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--color-charcoal);
}

.form-group small {
    display: block;
    margin-top: var(--space-xs);
    color: var(--color-slate);
    font-size: 0.85em;
}

input[type="text"],
input[type="file"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--color-lavender);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1em;
    transition: all 0.3s ease;
    background: var(--color-white);
}

input[type="text"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-lilac);
    box-shadow: 0 0 0 4px rgba(200, 182, 217, 0.1);
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-lilac);
}

body.redesign input[type="text"],
body.redesign input[type="file"],
body.redesign input[type="time"],
body.redesign select,
body.redesign textarea {
    border: 1px solid #DDD7E5;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.95em;
}

body.redesign input[type="text"]:focus,
body.redesign input[type="time"]:focus,
body.redesign select:focus,
body.redesign textarea:focus {
    border-color: var(--color-lilac);
    box-shadow: 0 0 0 3px rgba(200, 182, 217, 0.15);
}

body.redesign .form-group label {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: 6px;
}

body.redesign .form-group {
    margin-bottom: 18px;
}

body.redesign .form-group small {
    margin-top: 5px;
    font-size: 0.82em;
}

/* Upload Section */
.upload-section {
    background: var(--color-cream);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--color-lavender);
}

body.redesign .upload-section {
    background: var(--color-white);
    padding: 28px 32px;
    border-radius: 12px;
    border: 1px solid #ECE7F0;
    box-shadow: 0 1px 2px rgba(20, 16, 30, 0.03);
}

body.redesign div#drop-zone button {
    box-shadow: none;
    border-radius: 8px;
    border: 1px solid rgba(186, 142, 142, 0.25);
    transition: background-color 0.15s ease;
}

body.redesign .file-drop-zone {
    border: 1.5px dashed #D9CFE8;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

body.redesign .file-drop-zone:hover {
    border-color: var(--color-lilac);
    background: var(--color-cream);
}

.file-drop-zone {
    background: var(--color-white);
    border: 2px dashed var(--color-lavender);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-drop-zone:hover {
    border-color: var(--color-lilac);
    /* background: var(--color-lavender); */
        background: var(--gradient-warm);
}

.file-selected {
    background: var(--color-mint);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
}

.progress-bar {
    background: var(--color-cream);
    height: 8px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: var(--space-md);
}

.progress-fill {
    background: var(--gradient-primary);
    height: 100%;
    transition: width 0.3s ease;
}

/* Dependency Manager */
.dependency-manager {
    margin-top: var(--space-md);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 3000px;
    }
}

.dependency-manager-content {
    background: linear-gradient(135deg, var(--color-cream) 0%, var(--color-white) 100%);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border: 2px solid var(--color-lavender);
    box-shadow: var(--shadow-md);
}

.dep-section {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
}

.dep-item {
    background: var(--color-white);
    padding: var(--space-md);
    margin: var(--space-sm) 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-lavender);
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.dep-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.dep-name {
    flex: 1;
    font-weight: 500;
}

.dep-status {
    min-width: 120px;
    font-size: 0.85em;
}

/* Install Results */
.install-results {
    margin-top: var(--space-md);
}

.error {
    color: #C1121F;
}

.error-info {
    color: #C1121F;
    font-size: 0.9em;
}

.info {
    color: var(--color-slate);
    font-style: italic;
}

/* Job Cards & Monitoring */
.job-monitor {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--color-cream);
    border-radius: var(--radius-md);
}

.job-history {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.job-card,
.job-card-global {
    background: var(--color-white);
    padding: var(--space-md);
    margin: var(--space-sm) 0;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-slate);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.job-card:hover,
.job-card-global:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.job-card.done,
.job-card-global.done {
    border-left-color: var(--color-sage);
    /* background: linear-gradient(90deg, var(--color-mint) 0%, var(--color-white) 5%); */
    background: linear-gradient(90deg, var(--color-mint) 0%, var(--color-white) 160%);
}

.job-card.running,
.job-card-global.running {
    border-left-color: var(--color-coral);
    background: linear-gradient(90deg, var(--color-peach) 0%, var(--color-white) 5%);
}

.job-card.error,
.job-card-global.error {
    border-left-color: #FFB8A3;
    background: linear-gradient(90deg, var(--color-rose) 0%, var(--color-white) 5%);
}

.job-card.stopped {
    border-left-color: var(--color-slate);
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.job-info p {
    font-size: 0.9em;
    margin-bottom: var(--space-xs);
    color: var(--color-slate);
}

.job-logs {
    margin-top: var(--space-md);
    background: var(--color-charcoal);
    color: var(--color-cream);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    max-height: 300px;
    overflow-y: auto;
}

.output-files {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--color-cream);
    border-radius: var(--radius-sm);
}

.output-file {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.batch-badge {
    background: var(--color-sky);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.75em;
    font-weight: 600;
}

/* Activity Items */
.activity-item {
    /* background: var(--color-cream); */
    background: #ececec;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    text-transform: capitalize;
}

.activity-item strong {
    color: var(--color-charcoal);
}

.activity-item span {
    color: var(--color-slate);
    font-size: 0.9em;
}

/* Schedule Items */
.schedule-status {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.schedule-card {
    background: var(--color-cream);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin: var(--space-sm) 0;
    border-left: 4px solid var(--color-sage);
}

.day-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.day-checkboxes label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-weight: 400;
}

/* URL Management */
.url-editor-section {
    background: var(--color-cream);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}

.url-editor textarea {
    min-height: 200px;
    font-family: 'Monaco', monospace;
    font-size: 0.9em;
}

.url-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    margin-top: var(--space-md);
}

.batch-selector {
    margin-bottom: var(--space-md);
}

.url-result-item {
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
}

.url-result-item.success {
    background: var(--color-mint);
}

.url-result-item.error {
    background: var(--color-rose);
}

.url-scheduler-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 2px solid var(--color-lavender);
}

.url-schedule-item {
    background: var(--color-white);
    padding: var(--space-md);
    margin: var(--space-sm) 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-lavender);
}

.schedule-creator {
    background: var(--color-cream);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
        padding-left: 0px;
}
button.btn-primary[style="background:#6c757d;"],button.btn-primary[style="background:#6c757d; margin-top:15px;"] {
    background: var(--gradient-primary) !important;
}
button.nav-btn[onclick="showPage('jobs')"] {
    display: none !important;
}
/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: var(--space-sm);
    }
    
    header h1 {
        font-size: 2.5em;
    }
    
    .page {
        padding: var(--space-md);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .batch-actions,
    .file-actions,
    .url-actions {
        flex-direction: column;
    }
    
    .btn-small,
    .btn-mini {
        width: 100%;
        justify-content: center;
    }
    
    .dep-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--color-cream);
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-lilac);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

div#recent-activity .activity-item strong {
    width: 10%;
}
/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
    }
    
    .nav-btn,
    .btn-primary,
    .btn-small,
    .btn-mini {
        display: none;
    }
}

button.nav-btn[onclick="showPage('scheduler')"] {
    display: none !important;
}
.output-files .output-file {
    display: flex;
    justify-content: flex-start;
    gap: 2%;
}
.output-files .output-file span {
    width: 50%;
}
.output-files .output-file button {
    width: 15%;
}
.stat-card:nth-child(3) {
    display: none;
}
div#drop-zone button {
    padding: 10px 22px;
    margin-top: 10px;
    background: var(--gradient-warm);
    border: none;
    border-radius: 6px;
    box-shadow: 3px 3px 0px 0px #baa8a8;
}
/* ============================================================
   REDESIGN 2026-06 — Fixed top bar + left nav rail
   Old header/nav/.container/.page rules above are kept intact
   and unused, as a rollback path. This section supersedes them
   by overriding the same selectors with higher-specificity /
   later-cascade rules scoped to body.redesign.
   ============================================================ */

body.redesign {
    padding: 0;
    overflow: hidden; /* the shell below owns scrolling, not the body */
    background: var(--color-cream);
    background-attachment: scroll;
}

body.redesign::before {
    display: none; /* drop the grain texture overlay - it was designed to sit behind the old centered white card, not behind a full-bleed app shell */
}

body.redesign .container {
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
    animation: none;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---- Fixed top bar ---- */
body.redesign header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 500;
    background: var(--color-white);
    border-bottom: 1px solid #ECE7F0;
    padding: 0 var(--space-lg);
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 28px;
    overflow: visible;
}

body.redesign header h1 {
    font-size: 1.3em;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
    animation: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

body.redesign header p {
    display: none; /* tagline drops in the compact bar - the icon rail labels carry that context now */
}

/* Live status strip - the signature element: a calm, persistent system pulse */
.live-status-strip {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono, monospace);
    font-size: 0.78em;
    color: var(--color-slate);
    padding: 6px 14px;
    background: var(--color-cream);
    border-radius: var(--radius-full);
    border: 1px solid #F0E9F5;
    flex-shrink: 0;
    white-space: nowrap;
}

.live-status-strip .live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-sage);
    flex-shrink: 0;
}

.live-status-strip .live-dot.active {
    animation: liveDotPulse 1.8s ease-in-out infinite;
}

@keyframes liveDotPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(168, 201, 184, 0.5); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(168, 201, 184, 0); }
}

.live-status-strip strong {
    color: var(--color-charcoal);
    font-weight: 600;
}

/* ---- Shell: rail + content, sits below the fixed header ---- */
.app-shell {
    display: flex;
    flex: 1;
    margin-top: 60px;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* ---- Left icon rail (replaces the horizontal nav bar) ---- */
body.redesign nav {
    display: flex;
    flex-direction: column;
    width: 224px;
    flex-shrink: 0;
    background: var(--color-white);
    border-right: 1px solid #ECE7F0;
    padding: var(--space-lg) 14px;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-label {
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #9B8FAD;
    padding: 0 12px;
    margin: 18px 0 7px;
}

.nav-section-label:first-child {
    margin-top: 4px;
}

body.redesign .nav-btn {
    flex: none;
    min-width: 0;
    width: 100%;
    padding: 12px 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    font-size: 0.89em;
    font-weight: 500;
    font-family: var(--font-body);
    letter-spacing: 0.01em;
    border-radius: 2px;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    line-height: 1.2;
    text-align: left;
    color: var(--color-slate);
}

/* The emoji icon stays, but small and muted - a quiet wayfinding cue, not the focal point of the button */
body.redesign .nav-btn span:first-child {
    font-size: 1.05em;
    opacity: 0.7;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

body.redesign .nav-btn span:first-child svg {
    width: 18px;
    height: 18px;
    color: currentColor;
}

/* Inline icon used within headings/labels throughout the app (replaces colorful emoji) */
.icon-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -0.18em;
    color: var(--color-slate);
    opacity: 0.85;
}

.icon-inline svg {
    width: 1em;
    height: 1em;
    color: currentColor;
}

body.redesign .nav-btn::before {
    display: none; /* drop the animated underline - replaced by a left accent bar below */
}

body.redesign .nav-btn:hover {
    transform: none; /* no transform on hover - this is the lag fix */
    background: #F3ECFA;
    color: var(--color-charcoal);
}

body.redesign .nav-btn:hover span:first-child {
    opacity: 0.95;
}

body.redesign .nav-btn.active {
    background: var(--color-lavender);
    box-shadow: none;
    position: relative;
    color: var(--color-charcoal);
    font-weight: 600;
}

body.redesign .nav-btn.active span:first-child {
    opacity: 1;
}

body.redesign .nav-btn.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--color-charcoal);
    border-radius: 0 2px 2px 0;
}

/* ---- Scrolling content area ---- */
body.redesign .pages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--color-cream);
}

/* Section cards read as distinct elevated surfaces against the cream
   page background, instead of blending into it (both were the same
   cream color before, with only a thin border trying to separate them) */
body.redesign .section {
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    box-shadow: 0 1px 2px rgba(20, 16, 30, 0.03);
}

body.redesign .section-headline {
    background: linear-gradient(135deg, #FBF8FE 0%, #FFF9F5 100%);
    border: 1px solid #ECE0F5;
}

/* Quiet left-accent system - differentiates sections as you scroll down
   a long page, tied to the existing palette rather than introducing new
   colors. Subtle on purpose: a 3px rule, not a loud colored block. */
body.redesign .section-accent-sage,
body.redesign .section-accent-sky,
body.redesign .section-accent-rose {
    border-left: 3px solid transparent;
}

body.redesign .section-accent-sage {
    border-left-color: var(--color-sage);
}

body.redesign .section-accent-sky {
    border-left-color: #A8C8E8;
}

body.redesign .section-accent-rose {
    border-left-color: var(--color-rose);
}

body.redesign .section h3 {
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: none;
    margin-bottom: var(--space-md);
}

body.redesign .stat-card {
    background: var(--color-white);
    border: 1px solid #ECE7F0;
}

body.redesign .stats-grid {
    margin-bottom: 24px; /* was --space-xl (64px), wildly inconsistent with every other section's 24px rhythm */
}

.activity-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    transition: border-color 0.15s ease;
}

.activity-row:hover {
    border-color: var(--color-lavender);
}

.activity-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-row-main {
    flex: 1;
    min-width: 0;
}

.activity-row-top {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.activity-batch-name {
    font-weight: 600;
    color: var(--color-charcoal);
    font-size: 0.95em;
}

.activity-status-text {
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.activity-row-filename {
    font-size: 0.8em;
    color: #A8A2B3;
    font-family: var(--font-mono, monospace);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.activity-row-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.activity-mem-pill {
    font-size: 0.76em;
    color: var(--color-slate);
    background: var(--color-cream);
    padding: 2px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.activity-time {
    font-size: 0.8em;
    color: #B5AFC0;
    white-space: nowrap;
    min-width: 150px;
    text-align: right;
}

.dashboard-overview-row {
    display: flex;
    gap: 24px;
    align-items: stretch;
    margin-bottom: 24px;
}

.overview-col-left {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.overview-col-right {
    flex: 1;
    min-width: 0;
}

.status-hero-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.status-hero-card.section {
    margin-bottom: 0;
}

.status-hero-card h3 {
    color: var(--color-slate);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

p.stat-number.status-hero-value {
    font-size: 2.4em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.status-hero-value .icon-inline {
    font-size: 1em;
}

.status-mini-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card-mini {
    padding: 14px;
    text-align: center;
}

.stat-card-mini h3 {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-slate);
    margin-bottom: 6px;
}

.stat-card-mini p.stat-number {
    font-size: 1.5em;
    margin: 0;
}

@media (max-width: 980px) {
    .dashboard-overview-row {
        flex-direction: column;
    }
    .overview-col-left {
        flex: 1 1 auto;
        width: 100%;
    }
}


.admin-split-col {
    min-width: 0; /* allow content (e.g. wide tables) to shrink/scroll instead of overflowing */
}

.admin-split-main {
    flex: 0 0 66%;
    overflow-x: auto;
    padding-right: 28px;
}

.admin-split-side {
    flex: 1;
    padding-left: 28px;
    border-left: 1px solid #ECE7F0;
    display: flex;
    flex-direction: column;
}

.admin-split-side > div:last-child {
    flex: 1;
}

.admin-combined-section {
    display: flex;
    gap: 0;
    align-items: stretch;
}

@media (max-width: 980px) {
    .admin-combined-section {
        flex-direction: column;
    }
    .admin-split-main,
    .admin-split-side {
        flex: 1 1 auto;
        width: 100%;
        padding-right: 0;
    }
    .admin-split-side {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #ECE7F0;
        padding-top: 20px;
        margin-top: 20px;
    }
}

body.redesign .page {
    padding: var(--space-lg) 2rem;
    min-height: 0;
}

body.redesign .page.active {
    animation: none; /* drop the slide-in - keeps page switches feeling instant, not delayed */
}

/* ---- Cheap, non-laggy hover for cards (the Windows lag fix) ----
   Old .batch-card:hover animates transform+box-shadow over 0.4s on a
   large, content-heavy element - expensive to repaint, especially
   noticeable on Windows compositing. Replaced with a border/background
   color change only - GPU-cheap, no repaint of card contents. */
body.redesign .batch-card {
    transition: border-color 0.15s ease, background-color 0.15s ease;
    overflow: visible;
    position: relative;
    z-index: 1;
}

body.redesign .batch-card:has(.batch-overflow-menu.open) {
    z-index: 50;
}

body.redesign .batch-actions {
    overflow: visible;
    position: relative;
}

body.redesign .batch-header {
    margin-bottom: 12px;
}

body.redesign .batch-header h3 {
    margin: 0;
}

body.redesign .batch-info {
    margin-bottom: 14px;
}

body.redesign .batch-info p {
    margin-top: 0;
    margin-bottom: 4px;
}

body.redesign .batch-info p {
    margin: 3px 0;
    font-size: 0.88em;
}

body.redesign .batch-card:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--color-lavender);
}

body.redesign .batch-card::before {
    border-radius: 0 4px 4px 0;
}

body.redesign .stat-card,
body.redesign .file-item,
body.redesign .job-card,
body.redesign .job-card-global,
body.redesign .dep-item {
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

body.redesign .stat-card:hover,
body.redesign .file-item:hover,
body.redesign .job-card:hover,
body.redesign .job-card-global:hover,
body.redesign .dep-item:hover {
    transform: none;
    box-shadow: none;
}

/* ---- Per-action loading state (the double-click race fix) ---- */
.btn-mini.is-loading,
.btn-small.is-loading,
.btn-primary.is-loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
    color: transparent !important;
}

.btn-mini.is-loading::after,
.btn-small.is-loading::after,
.btn-primary.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(74, 74, 74, 0.25);
    border-top-color: var(--color-charcoal);
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

/* ---- Batch name autocomplete dropdown (Upload page) ---- */
.batch-name-autocomplete {
    position: relative;
}

.batch-name-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white);
    border: 1px solid #E0D9EC;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 28px rgba(89, 70, 122, 0.14), 0 2px 6px rgba(89, 70, 122, 0.08);
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 6px;
    display: none;
}

.batch-name-suggestions::before {
    content: 'Existing batches';
    display: block;
    padding: 9px 14px 7px;
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #B0A6C4;
    border-bottom: 1px solid #F1ECF7;
}

.batch-name-suggestions.open {
    display: block;
}

.batch-name-suggestion-item {
    padding: 11px 14px;
    cursor: pointer;
    font-size: 0.92em;
    color: var(--color-charcoal);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #F5F1FA;
}

.batch-name-suggestion-item:last-child {
    border-bottom: none;
}

.batch-name-suggestion-item .suggestion-name {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
}

.batch-name-suggestion-item .suggestion-name::before {
    content: '';
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background: var(--color-lavender);
    border-radius: 3px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23696077' stroke-width='2'%3E%3Cpath d='M3 7l9-4 9 4-9 4-9-4z' stroke-linejoin='round'/%3E%3Cpath d='M3 7v10l9 4 9-4V7' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 10px;
    background-repeat: no-repeat;
    background-position: center;
}

.batch-name-suggestion-item:hover,
.batch-name-suggestion-item.highlighted {
    background: #F6F1FB;
}

.batch-name-suggestion-item .suggestion-meta {
    font-size: 0.8em;
    color: var(--color-slate);
}

/* ---- Responsive: collapse rail to icons-only labels stay, but tighter, on narrow viewports ---- */
@media (max-width: 900px) {
    body.redesign nav {
        width: 64px;
        padding: var(--space-md) 6px;
    }
    body.redesign .nav-btn {
        flex-direction: column;
        gap: 3px;
        font-size: 0.6em;
        padding: 9px 2px;
        text-align: center;
    }
    body.redesign .nav-btn span:first-child {
        font-size: 1.15em;
        width: auto;
    }
    body.redesign .page {
        padding: var(--space-md);
    }
}

/* ============================================================
   REPORT MODALS (Batch Report / File Report) - redesign
   ============================================================ */
.report-modal-header {
    background: var(--color-white);
    border-bottom: 1px solid #ECE7F0;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-modal-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: var(--color-charcoal);
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-modal-header p {
    margin: 4px 0 0;
    color: var(--color-slate);
    font-size: 0.85em;
}

.report-run-select {
    padding: 9px 32px 9px 14px;
    border: 1px solid #DDD7E5;
    border-radius: 8px;
    font-size: 0.88em;
    background: var(--color-white);
    color: var(--color-charcoal);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23696077' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    min-height: 38px;
    max-width: 130px;
    box-sizing: border-box;
}

.report-download-btn {
    white-space: nowrap;
    height: 38px;
    box-sizing: border-box;
}

.report-modal-header > div:last-child {
    gap: 12px;
}

.report-close-btn {
    margin-left: 4px;
}

.report-download-btn {
    background: var(--color-mint) !important;
    border-color: #A8C9B8 !important;
    color: #166534 !important;
    font-weight: 600;
}

.report-download-btn:hover {
    background: #C5ECD6 !important;
}

.report-close-btn {
    background: none;
    border: none;
    color: var(--color-slate);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1em;
    transition: background-color 0.15s ease;
}

.report-close-btn:hover {
    background: var(--color-cream);
    color: var(--color-charcoal);
}

.report-stat-card {
    background: var(--color-cream);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    border: 1px solid #ECE7F0;
}

.report-stat-card .report-stat-icon {
    width: 28px;
    height: 28px;
    margin: 0 auto 6px;
}

.report-stat-card .report-stat-icon svg {
    width: 100%;
    height: 100%;
}

.report-stat-card .report-stat-value {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.2;
}

.report-stat-card .report-stat-label {
    font-size: 0.78em;
    color: var(--color-slate);
    margin-top: 2px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.report-table thead tr {
    background: var(--color-cream);
}

.report-table th {
    padding: 11px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--color-charcoal);
    border-bottom: 1px solid #ECE7F0;
    font-size: 0.92em;
    white-space: nowrap;
}

.report-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #F3F1F7;
}

.report-table tr.report-row-success {
    background: #F6FBF8;
}

.report-table tr.report-row-error {
    background: #FDF6F6;
}

.report-status-success {
    color: #166534;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.report-status-error {
    color: #B91C3C;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.report-status-icon {
    width: 14px;
    height: 14px;
    display: inline-flex;
}

.report-status-icon svg {
    width: 100%;
    height: 100%;
}

.report-memory-pill {
    font-family: var(--font-mono, monospace);
    font-size: 0.92em;
    color: var(--color-slate);
    background: var(--color-cream);
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.report-detail-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    background: none;
    border: none;
    padding: 2px 0;
}

.report-detail-link.report-link-error {
    color: #B91C3C;
}

.report-detail-link.report-link-log {
    color: #6366f1;
}

.report-footer-note {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--color-cream);
    border-radius: 8px;
    font-size: 0.85em;
    color: var(--color-charcoal);
    border: 1px solid #ECE7F0;
}

/* Batches page - sticky header so Refresh/Live indicator never require scrolling up */
.batches-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-cream);
    padding: 14px 0 16px;
    box-shadow: 0 1px 0 var(--color-cream);
}

.live-update-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: var(--color-slate);
    background: var(--color-white);
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid #ECE7F0;
}

.live-update-dot {
    width: 7px;
    height: 7px;
    background: var(--color-sage);
    border-radius: 50%;
    display: inline-block;
    animation: livePulse 2s infinite;
}

.batches-refresh-btn {
    background: var(--color-white) !important;
}

/* ============================================================
   FILE MANAGER MODAL ("Show in Folder") - redesign
   ============================================================ */
.fm-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 14px 20px;
    background: var(--color-cream);
    border-bottom: 1px solid #ECE7F0;
    flex-wrap: wrap;
}

.fm-upload-label {
    cursor: pointer;
}

.btn-accent-mint {
    background: var(--color-mint) !important;
    border-color: #A8C9B8 !important;
    color: #166534 !important;
    font-weight: 600;
}

.btn-accent-mint:hover {
    background: #C5ECD6 !important;
}

.fm-folder-row summary {
    list-style: none;
}

.fm-folder-row summary::-webkit-details-marker {
    display: none;
}

.fm-folder-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    margin-bottom: 4px;
}

.fm-folder-skipped {
    background: var(--color-cream);
    color: #B0AAB8;
}

.fm-tree-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    display: inline-flex;
    opacity: 0.65;
}

.fm-tree-icon svg {
    width: 100%;
    height: 100%;
}

.fm-folder-name {
    font-weight: 600;
    color: var(--color-charcoal);
    flex: 1;
}

.fm-folder-skipped .fm-folder-name {
    color: #B0AAB8;
}

.fm-skipped-note {
    font-size: 0.78em;
    color: #B0AAB8;
    white-space: nowrap;
}

.fm-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    background: var(--color-white);
    border: 1px solid #DDD7E5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78em;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--color-charcoal);
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.fm-action-btn:hover {
    background: var(--color-cream);
}

.fm-action-primary {
    background: var(--color-lavender) !important;
    border-color: #D9CFE8 !important;
}

.fm-action-primary:hover {
    background: #DCC9F0 !important;
}

.fm-action-icon-only {
    padding: 5px 8px;
}

.fm-action-icon-only svg {
    width: 12px;
    height: 12px;
    display: block;
}

.fm-action-icon {
    width: 12px;
    height: 12px;
    display: inline-flex;
    flex-shrink: 0;
}

.fm-action-icon svg, .fm-action-icon-only svg {
    width: 100%;
    height: 100%;
}

.fm-file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    margin-bottom: 3px;
    background: var(--color-white);
    border: 1px solid #F3F1F7;
    transition: background-color 0.12s ease;
}

.fm-file-row:hover {
    background: var(--color-cream);
}

.fm-file-checkbox {
    width: 15px;
    height: 15px;
    accent-color: var(--color-lilac);
    flex-shrink: 0;
}

.fm-file-name {
    flex: 1;
    font-size: 0.88em;
    color: var(--color-charcoal);
}

.fm-file-meta {
    font-size: 0.76em;
    color: #B0AAB8;
    white-space: nowrap;
}

.fm-icon-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 6px;
    transition: background-color 0.15s ease;
}

.fm-icon-btn svg {
    width: 100%;
    height: 100%;
}

.fm-icon-btn-download {
    background: #EEF2FF;
    color: #4338CA;
}

.fm-icon-btn-download:hover {
    background: #DCE3FF;
}

.fm-icon-btn-delete {
    background: #FDEEEE;
    color: #B91C3C;
}

.fm-icon-btn-delete:hover {
    background: #FBE0E0;
}

/* ============================================================
   MID MANAGER MODAL - redesign
   ============================================================ */
.btn-accent-amber {
    background: #FEF3E2 !important;
    color: #92400E !important;
    border-color: #F5DCAE !important;
    font-weight: 600;
}

.btn-accent-amber:hover {
    background: #FBE8C8 !important;
}

.mid-refresh-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
    color: var(--color-slate);
}

.mid-summary-bar {
    padding: 16px 24px;
    background: var(--color-cream);
    border-bottom: 1px solid #ECE7F0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mid-total-badge {
    display: inline-block;
    background: var(--color-white);
    color: var(--color-charcoal);
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.98em;
    font-weight: 700;
    width: fit-content;
    border: 1px solid #ECE7F0;
}

.mid-summary-cards {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.mid-summary-card {
    flex: 1;
    min-width: 160px;
    background: var(--color-white);
    border-radius: 10px;
    padding: 14px 16px;
    border: 1px solid #ECE7F0;
}

.mid-summary-card-title {
    font-weight: 700;
    color: var(--color-charcoal);
    margin-bottom: 10px;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 7px;
}

.mid-summary-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.mid-summary-icon svg {
    width: 100%;
    height: 100%;
}

.mid-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    margin-bottom: 5px;
    color: var(--color-charcoal);
}

.mid-summary-row:last-child {
    margin-bottom: 0;
}

.mid-summary-label {
    font-weight: 600;
}

.mid-summary-prod { color: #166534; }
.mid-summary-qa { color: #9333EA; }
.mid-summary-pending { color: #92400E; }

.mid-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 24px 0;
    border-bottom: 1px solid #ECE7F0;
    background: var(--color-cream);
}

.mid-tab-btn {
    padding: 9px 16px;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    font-family: var(--font-body);
    background: transparent;
    color: var(--color-slate);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mid-tab-btn:hover {
    background: rgba(255,255,255,0.5);
}

.mid-tab-active {
    background: var(--color-white) !important;
    color: #92400E !important;
}

.mid-legend {
    margin-top: 14px;
    padding: 14px 18px;
    background: var(--color-cream);
    border: 1px solid #ECE7F0;
    border-radius: 8px;
    font-size: 0.95em;
    color: var(--color-slate);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.mid-legend strong {
    color: var(--color-charcoal);
    margin-right: 4px;
}

.mid-legend-chip {
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    border-radius: 14px;
    padding: 5px 12px;
    white-space: nowrap;
}

.mid-legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mid-legend-icon {
    display: inline-flex;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.mid-legend-icon svg {
    width: 100%;
    height: 100%;
}

.mid-cell-icon {
    display: inline-flex;
    width: 17px;
    height: 17px;
    opacity: 0.85;
}

.mid-cell-icon svg {
    width: 100%;
    height: 100%;
}

/* ============================================================
   TESTING / QA REVIEW PAGE - redesign
   ============================================================ */
.qa-summary-banner {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    border-left: 3px solid var(--color-sage);
    border-radius: 10px;
    color: var(--color-charcoal);
}

.qa-batch-header {
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    padding: 20px 22px;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qa-batch-title-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.qa-batch-arrow {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: var(--color-slate);
    transition: transform 0.3s ease;
}

.qa-batch-arrow svg {
    width: 100%;
    height: 100%;
}

.btn-accent-indigo {
    background: #EEF2FF !important;
    color: #4338CA !important;
    border-color: #C7D2FE !important;
}

.btn-accent-indigo:hover {
    background: #E0E7FF !important;
}

.btn-accent-violet {
    background: #F3EBFB !important;
    color: #6B21A8 !important;
    border-color: #E0C9F0 !important;
}

.btn-accent-violet:hover {
    background: #EADCF7 !important;
}

.qa-type-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 6px;
    border-bottom: 2px solid #F3F1F7;
}

.qa-type-arrow {
    display: inline-flex;
    width: 15px;
    height: 15px;
    color: #B0AAB8;
    transition: transform 0.2s ease;
    transform: rotate(-90deg);
    flex-shrink: 0;
}

.qa-type-arrow svg {
    width: 100%;
    height: 100%;
}

.qa-type-icon {
    display: inline-flex;
    width: 19px;
    height: 19px;
    color: var(--color-slate);
    opacity: 0.75;
    flex-shrink: 0;
}

.qa-type-icon svg {
    width: 100%;
    height: 100%;
}

.qa-type-label {
    font-weight: 700;
    font-size: 1.15em;
    color: var(--color-charcoal);
}

.qa-type-count {
    background: var(--color-cream);
    color: var(--color-slate);
    padding: 3px 12px;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: 600;
}

.prod-merge-bar {
    position: sticky;
    bottom: 20px;
    background: var(--color-white);
    border: 1px solid #ECE7F0;
    padding: 18px 22px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(20, 16, 30, 0.1);
    margin-top: 30px;
}

body.redesign .btn-mini {
    background: var(--color-white);
    border: 1px solid #DDD7E5;
    border-radius: 7px;
    padding: 7px 12px;
    font-size: 0.85em;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

body.redesign .btn-mini:hover {
    transform: none;
    background: var(--color-cream);
    border-color: var(--color-lilac);
}

.btn-mini .btn-icon {
    display: inline-flex;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.btn-mini .btn-icon svg {
    width: 100%;
    height: 100%;
}

/* ============================================================
   STATUS PILL - for inert state indicators that sit among action
   buttons (e.g. "IN PROD", "In QA"). Deliberately muted and
   flat so it doesn't read as a clickable button at a glance.
   ============================================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-full, 999px);
    font-size: 0.9em;
    font-weight: 600;
    cursor: default;
    border: 1px dashed transparent;
    opacity: 0.85;
}

.status-pill .btn-icon svg {
    opacity: 0.8;
}

.status-pill-prod {
    background: #EEF7F1;
    color: #4B7A5E;
    border-color: #CFE6D7;
}

.status-pill-qa {
    background: #FBF3E7;
    color: #9A7340;
    border-color: #F0DDB8;
}

.status-pill-locked {
    background: var(--color-cream);
    color: #B0AAB8;
    border-color: #E5E0EB;
}