:root {
    /* Raum Network Theme */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-hover: #1a1a1a;
    --border-color: #27272a;
    --border-hover: #3f3f46;

    /* Text Colors */
    --text-primary: #ededed;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Accent Colors - Raum Green */
    --accent-primary: #4ade80;
    --accent-secondary: #059669;
    --accent-warning: #fbbf24;
    --accent-danger: #f87171;

    /* Status Colors */
    --status-new: #4ade80;
    --status-applied: #38bdf8;
    --status-reached: #fbbf24;
    --status-ping: #f87171;

    /* Effects */
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.5);

    /* Typography */
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

    /* Spacing */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;

    /* Additional variables from the snippet, resolving conflicts */
    --success: #00ff9d;
    --warning: #f1c40f;
    --danger: #ff4757;
    /* Re-defining text-primary, text-secondary, border-color, radius-sm, radius-md, radius-lg, shadow */
    --text-primary: #e0e0e0;
    /* Overwrites existing */
    --text-secondary: #a0a0a0;
    /* Overwrites existing */
    --border-color: #333;
    /* Overwrites existing */
    --radius-sm: 4px;
    /* Overwrites existing */
    --radius-md: 8px;
    /* Overwrites existing */
    --radius-lg: 12px;
    /* Overwrites existing */
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    /* New shadow variable */

    /* Header/Marquee specific */
    --marquee-bg: #0a0a0a;
    --marquee-text: #00ff9d;
    --marquee-height: 40px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
}

/* ============================================
   MARKET MARQUEE
   ============================================ */
.market-marquee-container {
    background: var(--marquee-bg);
    height: var(--marquee-height);
    width: 100%;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 1000;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    /* Prevent marquee collapsing */
}

.market-marquee {
    display: flex;
    white-space: nowrap;
    animation: marquee 70s linear infinite;
    padding-left: 100%;
}

.market-item {
    display: inline-flex;
    align-items: center;
    margin-right: 40px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.market-symbol {
    font-weight: 700;
    margin-right: 8px;
    color: var(--text-secondary);
}

.market-price {
    margin-right: 8px;
}

.market-change {
    font-size: 0.75rem;
}

.market-change.positive {
    color: var(--success);
}

.market-change.negative {
    color: var(--danger);
}

.marquee-loading {
    padding-left: 20px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    animation: blink 1.5s infinite;
}

/* ============================================
   PRELOADER
   ============================================ */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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

body.loaded #preloader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */
a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-primary);
}

.layout-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    /* Container doesn't scroll, children do */
    position: relative;
    /* Overridden on mobile */
}

/* Sidebar: Fixed width, independent scroll */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
}

/* Content: Fluid width, independent scroll */
.content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    /* Enable scroll here */
    background: var(--bg-primary);
    padding: 0;
    /* Remove default padding if any */
}

/* Ensure leads grid fits */
.leads-grid {
    padding: 0;
    width: 100%;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo-text .accent {
    color: var(--accent-primary);
    font-weight: 400;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.sidebar-section {
    margin-bottom: 28px;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* --- Controls in Sidebar --- */
.search-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 12px 14px;
    font-family: var(--font-main);
    font-size: 13px;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    outline: none;
    background: rgba(124, 92, 255, 0.05);
}

/* Next Scrape Timer */
.next-scrape-container {
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}

.next-scrape-timer {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.next-scrape-sources {
    font-size: 12px;
    color: var(--text-secondary);
}

.source-item {
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.next-scrape-scroll {
    max-height: 120px;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 1) 90%, transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 1) 90%, transparent 100%);
}

.next-scrape-scroll-content {
    animation: scroll-vertical 20s linear infinite;
}

.next-scrape-scroll-content:hover {
    animation-play-state: paused;
}

@keyframes scroll-vertical {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-50%);
    }
}

/* Filter Pills */
.filter-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: transparent;
    border: none;
}

.pill {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 10px 14px;
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.pill:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.pill.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Custom Select */
.custom-select {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 10px 14px;
    font-family: var(--font-main);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.custom-select:hover {
    border-color: var(--border-hover);
}

.custom-select:focus {
    border-color: var(--accent-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-secondary);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-secondary);
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-secondary);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--accent-secondary);
    }

    50% {
        opacity: 0.5;
        box-shadow: none;
    }
}

/* --- Status Badges --- */
.status-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.new {
    background: rgba(0, 212, 170, 0.15);
    color: var(--status-new);
}

.status-badge.applied {
    background: rgba(92, 158, 255, 0.15);
    color: var(--status-applied);
}

.status-badge.reached_out {
    background: rgba(255, 184, 0, 0.15);
    color: var(--status-reached);
}

.status-badge.ping_due {
    background: var(--status-ping);
    color: #fff;
    animation: pulse-red 2s infinite;
}

/* --- Action Buttons --- */
.action-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 14px;
    padding: 6px 10px;
    cursor: pointer;
    min-width: 32px;
    text-align: center;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.action-btn.ping-btn {
    border-color: var(--status-ping);
    color: var(--status-ping);
}

.action-btn.ping-btn:hover {
    background: var(--status-ping);
    border-color: var(--status-ping);
    color: #fff;
}

@keyframes pulse-red {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* --- Main Content --- */
/* ============================================
   COMPONENT UTILITIES
   ============================================ */

/* === JOB LISTING LAYOUT === */

.leads-grid {
    display: flex;
    flex-direction: column;
}

/* === DESKTOP: Single Row Layout === */
.lead-card {
    display: grid;
    grid-template-columns: 120px 1fr auto auto auto;
    grid-template-areas: "source title time actions save";
    align-items: center;
    gap: 20px;
    padding: 16px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.lead-card:first-child {
    border-top: 1px solid var(--border-color);
}

.lead-card:hover {
    background: var(--bg-card);
}

/* Source Tag */
.source-tag {
    grid-area: source;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

/* Job Title */
.card-title {
    grid-area: title;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.lead-card:hover .card-title a {
    color: var(--accent-primary);
}

/* Time & Status */
.card-meta {
    grid-area: time;
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-ago {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Action Buttons */
.action-row {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Save/Archive Buttons */
.header-actions {
    grid-area: save;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.lead-card:hover .header-actions {
    opacity: 1;
}

/* Buttons */
.save-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    transition: all 0.2s;
}

.save-btn:hover {
    color: var(--accent-warning);
    transform: scale(1.1);
}

.save-btn.saved {
    color: var(--accent-warning);
}

.archive-btn,
.restore-btn {
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
    transition: color 0.15s;
}

.archive-btn:hover {
    color: #e74c3c;
}

.restore-btn:hover {
    color: var(--success);
}

/* Hide old header */
.card-header {
    display: none;
}

.card-footer {
    display: none;
}

/* --- Utilities --- */
.loading {
    grid-column: 1 / -1;
    padding: 40px;
    display: flex;
    justify-content: center;
}

.loader {
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    animation: blink 0.5s infinite;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.empty-icon {
    display: block;
    margin-bottom: 10px;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-color);
    border: 1px solid var(--text-primary);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    transform: translateY(100px);
    transition: transform 0.2s;
    z-index: 200;
}

.toast.show {
    transform: translateY(0);
}

.toast-dot {
    width: 6px;
    height: 6px;
    background: var(--text-primary);
}

/* ============================================
   TABLET RESPONSIVENESS (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    /* Content handles itself via flex */

    .source-tag {
        min-width: 80px;
        max-width: 80px;
        font-size: 0.6rem;
    }

    .card-title {
        font-size: 0.75rem;
    }

    .action-btn {
        padding: 5px 10px;
    }
}

/* ============================================
   MOBILE RESPONSIVENESS (< 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Reset to native scroll */
    body {
        height: auto !important;
        overflow-y: auto !important;
        /* Allow body scroll */
    }

    .layout-container {
        flex-direction: column;
        height: auto !important;
        overflow: visible !important;
        /* Let content expand */
    }

    /* Sidebar becomes top navigation bar */
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
        /* Don't shrink */
        position: relative !important;
        /* Ensure dropdown positions correctly */
        overflow: visible !important;
        /* Allow dropdown to show */
        z-index: 1000 !important;
        /* Ensure on top of content */
    }

    .sidebar-header {
        padding: 12px 16px;
        z-index: 10002 !important;
        /* Higher than menu */
        position: relative;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        background: var(--bg-secondary);
        /* Ensure opaque background */
    }

    /* Hide scrollable sections by default on mobile */
    .sidebar-scroll {
        display: none !important;
        max-height: 100vh !important;
        overflow-y: auto;
        padding: 16px;
        padding-top: 100px !important;
        /* Clear header+marquee */
        border-top: none;
        background: var(--bg-secondary) !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        z-index: 10001 !important;
        /* Lower than header */
        box-shadow: none;
    }

    .sidebar-scroll.open {
        display: block !important;
    }

    .sidebar-footer {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
        /* Show the toggle button */
    }

    /* Content takes remaining height */
    .content {
        width: 100%;
        /* Remove margin/height overrides, flex handles it */
        height: auto !important;
        overflow: visible !important;
    }

    /* === MOBILE: Stacked Card Layout === */
    .lead-card {
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-rows: auto auto auto;
        /* Added row */
        grid-template-areas:
            "source time save"
            "title title title"
            "actions actions actions";
        gap: 8px 12px;
        padding: 12px 16px;
    }

    .lead-card:first-child {
        border-top: none;
    }

    .source-tag {
        grid-area: source;
        justify-self: start;
        font-size: 0.55rem;
        padding: 3px 6px;
    }

    .card-title {
        grid-area: title;
        white-space: normal;
        font-size: 0.8rem;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .card-meta {
        grid-area: time;
        justify-self: end;
    }

    .action-row {
        grid-area: actions;
        justify-self: start;
        margin-top: 4px;
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .header-actions {
        grid-area: save;
        justify-self: end;
        opacity: 1;
    }

    /* Adjust button sizes for touch */
    .action-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        flex: 1;
        /* Stretch buttons */
        justify-content: center;
    }

    .save-btn,
    .archive-btn,
    .restore-btn {
        padding: 6px;
        font-size: 1.1rem;
    }

    .status-badge {
        font-size: 0.55rem;
        padding: 2px 5px;
    }

    /* Filters - horizontal wrap */
    .filter-stack {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        background: transparent;
        border: none;
    }

    .pill {
        padding: 6px 10px;
        font-size: 0.7rem;
        flex: 1;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-item {
        padding: 8px;
    }

    .stat-value {
        font-size: 1rem;
    }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
    body {
        font-size: 12px;
    }

    .logo-text {
        font-size: 0.8rem;
    }

    .lead-card {
        padding: 12px;
        gap: 6px;
    }

    .source-tag {
        font-size: 0.5rem;
        padding: 2px 4px;
    }

    .card-title {
        font-size: 0.75rem;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    .time-ago {
        font-size: 0.6rem;
    }

    .action-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: 32px;
    }

    .pill {
        padding: 6px 10px;
        font-size: 0.6rem;
    }

    .search-input {
        padding: 8px;
        font-size: 0.75rem;
    }

    .toast {
        left: 10px;
        right: 10px;
        bottom: 10px;
        font-size: 0.7rem;
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
}

/* Archive/Restore button base styles */
.archive-btn,
.restore-btn {
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: all 0.15s ease;
    color: var(--text-secondary);
}

.archive-btn:hover {
    color: #e74c3c;
    opacity: 1;
}

.restore-btn:hover {
    color: var(--success);
    opacity: 1;
}