:root {
    /* Modern Stripe/Linear Default Palette */
    --color-primary: #0F62FE; /* Vivid Blue */
    --color-primary-dark: #0043CE;
    --color-secondary: #121619; /* Obsidian Black */
    
    --color-bg: #FAFAFB; /* Super Light Canvas */
    --color-surface: #FFFFFF;
    
    --color-text-main: #111827; 
    --color-text-secondary: #6B7280;
    --color-border: #E5E7EB;

    /* Multilayer Shadows for World-class UI */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    
    --shadow-glow: 0 0 15px rgba(var(--color-primary-rgb, 15, 98, 254), 0.3);

    /* Apple-like Smooth Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --header-height: 64px; /* Slightly taller for breathability */
    --sidebar-width: 44px; /* A bit more space for narrow state */
    --sidebar-width-expanded: 260px;

    /* Typographic perfection */
    --font-family-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base resets & typography rendering */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-body);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.01em; /* Modern tight tracking */
    transition: background-color 0.4s ease, color 0.4s ease;
}

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

/* Theme: Tech Noir (Blue) */
[data-theme="tech-noir"] {
    --color-primary: #2D4F8C;
    --color-primary-dark: #1e3a6e;
    --color-secondary: #0A1931;
    --color-bg: #F4F6F9;
    --color-surface: #FFFFFF;
    --color-text-main: #1A2340;
    --color-text-secondary: #6C757D;
    --color-border: #dce1e8;
}

/* Theme: Flux Energy (Orange) */
[data-theme="flux-energy"] {
    --color-primary: #FF6B35;
    --color-primary-dark: #e55a2b;
    --color-secondary: #0A1931;
    --color-bg: #E9ECEF;
    --color-surface: #FFFFFF;
    --color-text-main: #212529;
    --color-text-secondary: #495057;
    --color-border: #ced4da;
}

/* Theme: Smart Growth (Teal) */
[data-theme="smart-growth"] {
    --color-primary: #00B8A9;
    --color-primary-dark: #009689;
    --color-secondary: #121D33;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-text-main: #1A2340;
    --color-text-secondary: #64748b;
    --color-border: #e2e8f0;
}

/* Theme: Future Minimalist (Cyan) */
[data-theme="future-minimalist"] {
    --color-primary: #04b4d4;
    --color-primary-dark: #0390aa;
    --color-secondary: #0A1931;
    --color-bg: #F1F3F4;
    --color-surface: #FFFFFF;
    --color-text-main: #0A1931;
    --color-text-secondary: #5f6368;
    --color-border: #dadce0;
}

/* ============================================
   DARK THEMES - REFINED V2 (strict 5-Color Palette)
   ============================================
   User Rule: Kanban Column (Surface) must be LIGHTER than Card.
   Structure:
   1. --color-bg (Page Background) - Darkest
   2. --color-card (Deal Cards) - Dark
   3. --color-surface (Kanban Columns) - Lighter than Card
   4. --color-text-main: #ffffff (White)
   5. --color-text-secondary: #9ca3af (Gray)
   ============================================ */

/* Common Dark Theme Mixins */
[data-theme="midnight-neon"],
[data-theme="cyber-glass"],
[data-theme="dark-luxe"],
[data-theme="aurora-borealis"],
[data-theme="crimson-night"],
[data-theme="toxic-protocol"],
[data-theme="royal-amethyst"],
[data-theme="oceanic-depth"],
[data-theme="dark-mode"] {
    --color-text-main: #ffffff !important;
    --color-text-secondary: #9ca3af !important;
    --font-weight-bold: 600;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

/* 1. Carbon Classic (Neutral/Gray) */
[data-theme="midnight-neon"] {
    --color-primary: #3b82f6;
    --color-bg: #09090b; /* Zinc 950 */
    --color-card: #18181b; /* Zinc 900 */
    --color-surface: #27272a; /* Zinc 800 */
    --color-border: #3f3f46;
    --glow-color: rgba(59, 130, 246, 0.4);
}

/* 2. Nordic Night (Blue-Grey) */
[data-theme="cyber-glass"] {
    --color-primary: #38bdf8;
    --color-bg: #0f172a; /* Slate 900 */
    --color-card: #1e293b; /* Slate 800 */
    --color-surface: #334155; /* Slate 700 */
    --color-border: #475569;
    --glow-color: rgba(56, 189, 248, 0.3);
}

/* 3. Vintage Warm (Gruvbox) */
[data-theme="dark-luxe"] {
    --color-primary: #f59e0b;
    --color-bg: #171717; /* Neutral 900 */
    --color-card: #262626; /* Neutral 800 */
    --color-surface: #404040; /* Neutral 700 */
    --color-border: #525252;
    --glow-color: rgba(245, 158, 11, 0.25);
}

/* 4. Deep Forest (Green) */
[data-theme="aurora-borealis"] {
    --color-primary: #10b981;
    --color-bg: #022c22; /* Emerald 950 */
    --color-card: #064e3b; /* Emerald 900 */
    --color-surface: #065f46; /* Emerald 800 */
    --color-border: #047857;
    --glow-color: rgba(16, 185, 129, 0.35);
}

/* 5. Vampire Classic (Red) */
[data-theme="crimson-night"] {
    --color-primary: #f43f5e;
    --color-bg: #2e020f; /* Rose 950 */
    --color-card: #4c0519; /* Rose 900 */
    --color-surface: #881337; /* Rose 800 */
    --color-border: #9f1239;
    --glow-color: rgba(244, 63, 94, 0.35);
}

/* 6. Matrix Code (Green/Black) */
[data-theme="toxic-protocol"] {
    --color-primary: #84cc16;
    --color-bg: #050505;
    --color-card: #121212;
    --color-surface: #202020;
    --color-border: #333333;
    --glow-color: rgba(132, 204, 22, 0.3);
}

/* 7. Cyberpunk Purple */
[data-theme="royal-amethyst"] {
    --color-primary: #d946ef;
    --color-bg: #1e1b4b; /* Indigo 950 */
    --color-card: #2e1065; /* Violet 950 */
    --color-surface: #4c1d95; /* Violet 900 */
    --color-border: #5b21b6;
    --glow-color: rgba(217, 70, 239, 0.4);
}

/* 8. Navy Vintage */
[data-theme="oceanic-depth"] {
    --color-primary: #6366f1;
    --color-bg: #040816;
    --color-card: #0c142e;
    --color-surface: #1e293b;
    --color-border: #334155;
    --glow-color: rgba(99, 102, 241, 0.3);
}

/* 9. Dark Mode - Clean Universal Dark */
[data-theme="dark-mode"] {
    --color-primary: #C5F22B; /* World-class absolute neon green/yellow */
    --color-primary-dark: #b1d927;
    --color-secondary: #0A0A0B;
    --color-bg: #09090b; /* Pitch Black Zinc */
    --color-card: #18181b; /* Zinc 900 */
    --color-surface: #27272a; /* Zinc 800 */
    --color-border: #3f3f46;
    --color-text-main: #FAFAFA;
    --color-text-secondary: #A1A1AA;
    --glow-color: rgba(197, 242, 43, 0.2);
}

/* --- Universal Dark Theme Glows & Effects --- */

/* Top Bar: dark */
[data-theme="midnight-neon"] .top-bar,
[data-theme="cyber-glass"] .top-bar,
[data-theme="dark-luxe"] .top-bar,
[data-theme="aurora-borealis"] .top-bar,
[data-theme="crimson-night"] .top-bar,
[data-theme="toxic-protocol"] .top-bar,
[data-theme="royal-amethyst"] .top-bar,
[data-theme="oceanic-depth"] .top-bar,
[data-theme="dark-mode"] .top-bar {
    background-color: rgba(255, 255, 255, 0.04);
    border-bottom-color: var(--color-border);
}

/* Sidebar Gradient & Glow */
[data-theme="midnight-neon"] .sidebar,
[data-theme="crimson-night"] .sidebar,
[data-theme="royal-amethyst"] .sidebar {
    background: linear-gradient(180deg, var(--color-secondary) 0%, var(--color-bg) 100%);
    border-right: 1px solid var(--color-border);
    box-shadow: 2px 0 15px var(--glow-color);
}

[data-theme="cyber-glass"] .sidebar,
[data-theme="aurora-borealis"] .sidebar,
[data-theme="oceanic-depth"] .sidebar {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--color-border);
}

/* Card Glows */
[data-theme="midnight-neon"] .card,
[data-theme="crimson-night"] .card,
[data-theme="toxic-protocol"] .card {
    border: 1px solid var(--color-border);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.2);
}

[data-theme="cyber-glass"] .card,
[data-theme="oceanic-depth"] .card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Primary Button Neon Glow */
[data-theme="midnight-neon"] .btn-primary,
[data-theme="crimson-night"] .btn-primary,
[data-theme="toxic-protocol"] .btn-primary,
[data-theme="royal-amethyst"] .btn-primary,
[data-theme="cyber-glass"] .btn-primary {
    box-shadow: 0 0 12px var(--glow-color);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    border: none;
    letter-spacing: 0.5px;
}

[data-theme="midnight-neon"] .btn-primary:hover,
[data-theme="crimson-night"] .btn-primary:hover {
    box-shadow: 0 0 20px var(--glow-color);
    transform: translateY(-1px);
}

/* Text Overrides for Readability */
[data-theme="midnight-neon"] h1,
[data-theme="midnight-neon"] h2,
[data-theme="midnight-neon"] h3,
[data-theme="crimson-night"] h1,
[data-theme="crimson-night"] h2,
[data-theme="crimson-night"] h3,
[data-theme="toxic-protocol"] h1,
[data-theme="toxic-protocol"] h2,
[data-theme="toxic-protocol"] h3 {
    text-shadow: 0 0 5px var(--glow-color);
}

/* Theme Dot Colors (for Settings Selector) */
.theme-green {
    background-color: #009c63;
}

.theme-blue {
    background-color: #2D4F8C;
}

.theme-orange {
    background-color: #FF6B35;
}

.theme-cyan {
    background-color: #04b4d4;
}

.theme-teal {
    background-color: #00B8A9;
}

/* Dark Theme Dots */
.theme-neon-purple {
    background: linear-gradient(135deg, #d946ef, #4c1d95);
}

.theme-neon-teal {
    background: linear-gradient(135deg, #2dd4bf, #0f766e);
}

.theme-neon-gold {
    background: linear-gradient(135deg, #fbbf24, #78350f);
}

.theme-neon-green {
    background: linear-gradient(135deg, #4ade80, #064e3b);
}

.theme-neon-red {
    background: linear-gradient(135deg, #f87171, #7f1d1d);
}

.theme-neon-lime {
    background: linear-gradient(135deg, #a3e635, #3f6212);
}

.theme-neon-violet {
    background: linear-gradient(135deg, #c084fc, #581c87);
}

.theme-neon-blue {
    background: linear-gradient(135deg, #38bdf8, #075985);
}


/* ============================================
   REMOVED OLD THEME BOILERPLATE
   Redesigned later via unified approaches if desired
   ============================================ */

/* Global Smooth Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 150, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(150, 150, 150, 0.5);
}

/* Layout */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: rgba(18, 22, 25, 0.95); /* Deep translucent */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
    z-index: 2000;
    overflow: hidden;
    box-shadow: 1px 0 20px rgba(0,0,0,0.05);
}

.sidebar:hover,
.sidebar.expanded {
    width: var(--sidebar-width-expanded);
    align-items: flex-start;
}

.sidebar-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    height: 48px;
    justify-content: flex-start;
    color: #9CA3AF;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, background-color 0.2s, padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.sidebar-item:hover,
.sidebar-item.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-item i {
    font-size: 18px;
    width: 36px;
    /* Match sidebar width */
    min-width: 36px;
    /* Enforce width */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* No margin when collapsed */
}

.sidebar:hover .sidebar-item,
.sidebar.expanded .sidebar-item {
    padding: 0 16px;
    /* Restore padding on hover */
}

.sidebar:hover .sidebar-item i,
.sidebar.expanded .sidebar-item i {
    width: auto;
    /* Reset width */
    min-width: 24px;
    margin-right: 12px;
    /* Restore margin */
    justify-content: center;
}

.sidebar-item span {
    opacity: 0;
    width: 0;
    /* Hide completely */
    margin-left: 0;
    overflow: hidden;
    transition: opacity 0.2s, width 0s 0.2s;
    /* Delay width to allow fade out */
}

.sidebar:hover .sidebar-item span,
.sidebar.expanded .sidebar-item span {
    opacity: 1;
    width: auto;
    transition: opacity 0.2s, width 0s;
}

/* ============================================
   DARK MODE TOGGLE - Sidebar Button Aesthetics
   ============================================ */

/* Ícone lua — aparece quando o modo claro está ativo */
#dark-mode-toggle i.fa-moon {
    color: #b0b3b5;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                color 0.3s ease,
                filter 0.3s ease;
}

#dark-mode-toggle:hover i.fa-moon {
    color: #c084fc;
    filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.7));
    transform: rotate(-20deg) scale(1.25);
}

/* Ícone sol — aparece quando o dark mode está ativo */
#dark-mode-toggle i.fa-sun {
    color: #fbbf24;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.9));
    animation: darkModeSunPulse 3s ease-in-out infinite;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#dark-mode-toggle:hover i.fa-sun {
    transform: rotate(30deg) scale(1.25);
    animation: none;
    filter: drop-shadow(0 0 14px rgba(251, 191, 36, 1));
}

@keyframes darkModeSunPulse {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.9)); }
    50%       { filter: drop-shadow(0 0 16px rgba(251, 191, 36, 1)); }
}

/* Destaque visual quando dark mode está ativo */
[data-theme="dark-mode"] #dark-mode-toggle {
    background: linear-gradient(90deg, rgba(88, 166, 255, 0.10), transparent);
    border-left: 2px solid rgba(88, 166, 255, 0.5);
}

[data-theme="dark-mode"] #dark-mode-toggle:hover {
    background: linear-gradient(90deg, rgba(88, 166, 255, 0.18), transparent);
}

/* Centered Wrapper for Task View */
.centered-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Top Bar */
.top-bar {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 20px 0 24px;
    gap: 16px;
    position: relative;
    z-index: 1000;
}

.top-bar-logo {
    height: 40px;
    width: auto;
    flex-shrink: 0;
    object-fit: contain;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text-main);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Top bar right actions group */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Universal Search */
.header-search-wrapper {
    flex: 1;
    max-width: 480px;
    display: none;
    position: relative;
    z-index: 10;
}

.header-search-box {
    display: flex;
    align-items: center;
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.header-search-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.1);
}

.header-search-icon {
    color: var(--color-text-secondary);
    margin-right: 10px;
    font-size: 14px;
    flex-shrink: 0;
}

.header-search-input {
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    font-size: 14px;
    font-family: var(--font-family-body);
    color: var(--color-text-main);
    width: 100%;
}

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

.header-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    max-height: 450px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
}

/* Theme separator in pill */
.theme-separator {
    display: inline-block;
    width: 1px;
    height: 16px;
    background: var(--color-border);
    margin: 0 4px;
    vertical-align: middle;
}

/* View Area */
.view-container {
    padding: 28px 32px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.loading::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

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

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
    text-align: center;
    color: var(--color-text-secondary);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.35;
    color: var(--color-text-secondary);
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-main);
    margin-bottom: 6px;
}

.empty-state-desc {
    font-size: 13.5px;
    max-width: 340px;
    line-height: 1.55;
}

/* Settings tab bar */
.settings-tab-bar .btn {
    font-size: 13px;
    padding: 6px 14px;
    white-space: nowrap;
    border-radius: var(--radius-sm);
}

/* ============================================
   BUTTON SYSTEM — Consistent & Professional
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13.5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary */
.btn-primary {
    background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-primary:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 14px rgba(15, 98, 254, 0.28);
    transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-main);
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--color-bg);
    border-color: #c5c9d0;
    transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover {
    background: rgba(0,0,0,0.05);
    color: var(--color-text-main);
}

/* Danger */
.btn-danger {
    background: #ef4444;
    color: #fff;
    border-color: transparent;
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

/* Small variant */
.btn-sm {
    padding: 5px 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

/* Components: Card */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    padding: 16px;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 20px;
    height: 100%;
    overflow-x: auto;
    padding-bottom: 24px;
    padding-left: 4px;
}

.kanban-column {
    min-width: 280px;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: var(--radius-lg);
    background-color: transparent;
}

.kanban-header {
    padding: 16px 8px;
    font-weight: 700;
    color: var(--color-text-main);
    border-bottom: 2px solid transparent;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.kanban-column:nth-child(even) .kanban-header {
    /* Optional: Alternating slight variations if needed */
}

.kanban-cards {
    flex: 1 1 auto;
    overflow-y: visible;
    padding: 8px 4px;
    min-height: 0;
    --card-font-base: 14px;
}

.deal-card {
    background: var(--color-card, var(--color-surface)) !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0;
    margin-bottom: 12px;
    cursor: grab;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, border-color 0.3s ease;
    border-left: 4px solid var(--color-primary);
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: min-content;
    overflow: visible;
    font-size: var(--card-font-base);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    position: relative;
    will-change: transform;
}

.deal-card:hover {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(var(--color-primary-rgb, 15, 98, 254), 0.1);
    transform: translateY(-4px) scale(1.02);
    z-index: 100;
}

/* Fix for stacking: Lift column when card is hovered */
.kanban-column:has(.deal-card:hover) {
    z-index: 50;
    position: relative;
    overflow: visible;
    /* Try to allow pop-out if possible */
}

.deal-title {
    font-weight: 700;
    font-size: 1.1em;
    /* Relative to base */
    color: var(--color-text-main);
    margin-bottom: 4px;
    line-height: 1.3;
    text-align: justify;
    /* Justified text */
}

.deal-contact {
    font-size: 1em;
    /* Increased from 0.9em */
    font-weight: 600;
    /* Bold as requested */
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    /* Allow wrapping */
}

.deal-contact i {
    margin-right: 6px;
    font-size: 0.9em;
}

.deal-divider {
    height: 1px;
    background-color: #f1f3f5;
    margin: 8px 0 12px 0;
}

.deal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* Wraps items if too tight */
    gap: 4px;
    /* Reduced gap for tight spaces */
}



.task-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    /* Narrower padding per user request */
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    margin-right: 8px;
}

.task-badge i {
    margin-right: 4px;
}

.deal-value {
    font-weight: 700;
    font-size: 1em;
    /* Relative to base */
    color: var(--color-primary);
    /* Changed to theme color per user request */
}

/* Drop Target Highlight */
.kanban-cards.drag-over {
    background-color: #e3fcef;
    border-radius: var(--radius-md);
}

/* Task List */
.task-list {
    width: 100%;
    border-collapse: collapse;
}

.task-list th,
.task-list td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
}

.task-list th {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5); /* Semi-transparent base */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px 0;
    opacity: 1;
    animation: fadeIn 0.2s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Specific styling for Deal Details full-screen overlay */
#deal-details-overlay {
    position: absolute !important;
    /* Override fixed from parent class */
    top: 0;
    left: 0 !important;
    width: 100% !important;
    height: 100%;
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
    z-index: 1000;
    overflow-y: hidden;
    animation: none !important;
    opacity: 1 !important;
}

/* ============================================
   DEAL DETAILS - Scroll Único na Página Toda
   Abordagem: o overlay é o único container de
   scroll. Modal, body e colunas crescem
   naturalmente. Sem scrollbars individuais.
   ============================================ */

/* Overlay: único scroll da página */
#deal-details-overlay {
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border, #c1c7d0) var(--color-bg, #f4f5f7);
}

/* Modal: cresce com o conteúdo em vez de fixar em 100% */
#deal-details-overlay > .modal {
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
}

/* Header: não encolhe, rola junto com a página */
#deal-details-overlay .modal-header {
    flex-shrink: 0 !important;
}

/* Body: altura natural, sem overflow próprio */
#deal-details-overlay .modal-body {
    flex: none !important;
    overflow: visible !important;
    min-height: auto !important;
}

/* Todas as colunas: sem scroll individual, crescem com conteúdo */
#deal-details-overlay #col-details,
#deal-details-overlay #col-notes,
#deal-details-overlay #col-people {
    overflow: visible !important;
}

/* Containers internos: sem scroll, expandem naturalmente */
#deal-details-overlay #custom-fields-container,
#deal-details-overlay #notes-container {
    overflow: visible !important;
    flex: none !important;
    min-height: auto !important;
    max-height: none !important;
}

#deal-details-overlay #tasks-list {
    overflow: visible !important;
    flex: none !important;
}

#deal-details-overlay #col-people > div:last-child {
    flex: none !important;
}

/* Flex children: não encolhem (evita compressão) */
#deal-details-overlay #notes-container > *,
#deal-details-overlay #custom-fields-container > *,
#deal-details-overlay #col-people > * {
    flex-shrink: 0 !important;
}

/* --- Scrollbar estilizada (única, no overlay) --- */
#deal-details-overlay::-webkit-scrollbar {
    width: 8px;
}

#deal-details-overlay::-webkit-scrollbar-track {
    background: var(--color-bg, #f4f5f7);
}

#deal-details-overlay::-webkit-scrollbar-thumb {
    background: var(--color-border, #c1c7d0);
    border-radius: 4px;
}

#deal-details-overlay::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary, #747678);
}

/* Esconde a seção de valor antiga e o divisor na barra de status.
   O valor agora fica ao lado do título do negócio (linha de cima). */
#deal-details-overlay .modal-header > div:nth-child(2) > div:nth-child(1),
#deal-details-overlay .modal-header > div:nth-child(2) > div:nth-child(2) {
    display: none !important;
}

.custom-modal {
    background: var(--color-surface);
    width: 500px;
    max-height: 90vh;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    transform: scale(0.98);
    animation: scaleModal 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleModal {
    to { transform: scale(1); }
}

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

.custom-modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.custom-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Helper */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main);
    letter-spacing: -0.01em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: var(--font-family-body);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.form-select {
    padding-right: 36px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-surface);
    box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.12);
}

.form-input::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.7;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25em 0.8em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 50px;
    /* Rounded pill shape */
}

.badge-primary {
    color: #fff;
    background-color: var(--color-primary);
}

.badge-blue {
    color: #fff;
    background-color: #3b82f6;
    /* Blue 500 */
}

.badge-amber {
    color: #fff;
    background-color: #f59e0b;
    /* Amber 500 */
}

.badge-red {
    color: #fff;
    background-color: #f43f5e;
    /* Rose 500 */
}

/* Badge Square */
.badge-square {
    display: inline-block;
    padding: 0.25em 0.8em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
    /* Square with slight radius */
    color: #fff;
}

/* Task Row Styles */
.task-row-completed {
    background-color: #d1fae5 !important;
    /* Light Green */
}

.task-row-overdue {
    background-color: #fee2e2 !important;
    /* Light Red */
}

.task-row-pending {
    background-color: #f3f4f6 !important;
    /* Light Gray */
}

/* First column spacing */
.task-list th:first-child,
.task-list td:first-child {
    padding-left: 24px;
}

/* Task Cards */
/* Task Row (Refined List Style) */
.task-row {
    background: var(--color-surface);
    border-bottom: 1px solid #f0f0f0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    gap: 16px;
}

.task-row:hover {
    background-color: #fafafa;
}

.task-row:last-child {
    border-bottom: none;
}

/* Status Indicators (Mini dots or icons instead of thick borders) */
.task-row.status-completed .task-title {
    text-decoration: line-through;
    color: #999 !important;
}

.task-row.status-overdue {
    border-left: 3px solid #ef4444;
}

.task-row.status-overdue .task-title {
    color: #dc2626 !important;
}

.task-row.status-completed {
    border-left: 3px solid #009c63;
}

.task-row.status-pending {
    border-left: 3px solid #4b5563;
}

/* Deal Card Task Badges */
.task-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    margin-right: 8px;
}

.badge-overdue {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.pulse-badge {
    animation: pulse-zoom 0.8s infinite ease-in-out;
}

.badge-future {
    background-color: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.badge-empty {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

/* Pending/To Do: Dark Gray */
.task-row.status-pending {
    border-color: #4b5563;
}

.task-row:hover .task-actions {
    opacity: 1;
}

.task-actions {
    opacity: 0;
    display: flex;
    gap: 8px;
    transition: opacity 0.2s;
}


/* Deal Badge */
.task-deal-badge {
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    display: inline-block;
}

.task-check-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-options-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.task-card:hover .task-options-btn {
    opacity: 1;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: #f3f4f6;
}

/* Theme Selector Pill */
.theme-selector-pill {
    display: flex;
    align-items: center;
    background-color: #f1f3f4;
    padding: 4px 8px;
    border-radius: 50px;
    gap: 4px;
    border: 1px solid #e0e0e0;
}

.theme-label {
    font-size: 0.65em;
    font-weight: 700;
    color: #5f6368;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 2px;
}

.theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    padding: 0;
}

.theme-dot:hover {
    transform: scale(1.1);
}

.theme-dot.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px white, 0 0 0 4px rgba(0, 0, 0, 0.1);
}

/* Theme Dot Colors */
.theme-green {
    background-color: #009c63;
}

.theme-blue {
    background-color: #2D4F8C;
}

.theme-orange {
    background-color: #FF6B35;
}

.theme-cyan {
    background-color: #04b4d4;
}

/* Pipeline Progress Bar */
.pipeline-progress {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Align top so dots line up */
    position: relative;
    width: 100%;
    margin-top: 10px;
}

/* Background Line */
.pipeline-progress::before {
    content: '';
    position: absolute;
    top: 12px;
    /* Center of 24px dot (12px radius) */
    left: 12px;
    /* Start center of first dot */
    right: 12px;
    /* End center of last dot */
    height: 3px;
    background-color: #e0e0e0;
    z-index: 1;
}

/* Progress Fill Line */
.pipeline-progress-fill {
    position: absolute;
    top: 12px;
    left: 12px;
    height: 3px;
    background-color: var(--color-primary);
    z-index: 2;
    transition: width 0.3s ease;
}

.pipeline-step {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    flex: 1;
}

.pipeline-step:hover .pipeline-dot {
    transform: scale(1.1);
}

.pipeline-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #fff;
    border: 3px solid #e0e0e0;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    position: relative;
}

/* Completed State */
.pipeline-step.completed .pipeline-dot {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Active State */
.pipeline-step.active .pipeline-dot {
    background-color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 156, 99, 0.2);
    transform: scale(1.1);
}

/* Inner dot for active state */
.pipeline-step.active .pipeline-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--color-primary);
    border-radius: 50%;
}

.pipeline-label {
    font-size: 11px;
    color: #999;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    transition: color 0.3s;
    padding: 0 4px;
    /* Prevent text touching */
}


/* Utility for full width view */
.no-padding {
    padding: 0 !important;
}

/* Excel Spreadsheet Grid */
.spreadsheet-container {
    width: 100% !important;
    height: calc(100vh - 120px);
    overflow: auto;
    border-top: 1px solid #777;
    background: #fff;
    margin: 0;
}

.spreadsheet-table {
    border-collapse: collapse !important;
    width: 100%;
    table-layout: fixed;
    border: 1px solid #777 !important;
}

.spreadsheet-table th,
.spreadsheet-table td {
    border: 1px solid #777 !important;
    /* Authentic dark borders */
    padding: 2px 8px;
    height: 30px;
    font-size: 13px;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
    position: relative;
    box-sizing: border-box;
}

.spreadsheet-table th {
    background-color: #e6e6e6 !important;
    font-weight: bold;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #777 !important;
    overflow: visible !important;
    /* Vital for resizers to work */
}

/* Container for text truncation inside sticky th */
.th-content {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spreadsheet-table tr:hover td {
    background-color: #d8e6f3 !important;
}

.spreadsheet-table tbody tr {
    cursor: pointer;
}

/* Specific Priority Badge for Excel style */
.spreadsheet-table .badge {
    padding: 0 4px;
    font-size: 11px;
    border-radius: 2px;
}

/* Resizer handle for column borders */
.resizer {
    position: absolute;
    right: -4px;
    /* Center over the border */
    top: 0;
    height: 100%;
    width: 8px;
    /* Wider hit area */
    background: transparent;
    cursor: col-resize;
    z-index: 20;
}

.resizer:hover,
.resizing .resizer {
    background-color: #4b89ff;
    width: 2px;
    right: 0;
}

/* Refined Excel Styles */
.overdue-row td {
    color: #d32f2f !important;
    /* Red text for overdue */
    background-color: #fff !important;
    /* Reset background to white */
    font-weight: 700 !important;
    /* Bold text for overdue */
}

.completed-row td {
    color: #2e7d32 !important;
    /* Green text for completed */
}

.priority-cell {
    text-align: center !important;
}

.priority-cell .badge {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 55px;
    max-width: 60px;
    padding: 6px 10px;
    margin: 0 auto;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Much Larger Square Checkbox */
.task-check-square {
    font-size: 28px !important;
    /* Bem maior */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    background: #fff;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.task-check-square.completed {
    color: var(--color-primary) !important;
    /* Green icon */
    background: #fff !important;
    /* White behind the hole makes the check white */
}

/* Ensure the checkmark itself is white if it's fa-square-check */
.task-check-square.completed .fa-square-check {
    background-color: #fff;
    color: var(--color-primary);
    border-radius: 4px;
}

/* Cancelled state: grey X checkbox */
.task-check-square.cancelled {
    color: #bbb !important;
    background: #fff !important;
    cursor: default !important;
}

.task-check-square.cancelled .fa-square-xmark {
    background-color: #fff;
    color: #bbb !important;
    border-radius: 4px;
}

/* Alternative approach for pure white check: use layers or just ensure background is white */
/* Helper for spreadsheet centering */
.spreadsheet-table td.priority-cell {
    padding: 0;
    vertical-align: middle;
}

.spreadsheet-table td:first-child {
    padding: 0;
    width: 60px;
    /* Wider for the much larger checkbox */
    text-align: center;
}

/* ============================================================ */
/* Kanban Card Extra 3D Removed / Refined for Modernity */
/* ============================================================ */
.deal-card {
    border-radius: var(--radius-md) !important;
}

.deal-card:active {
    transform: translateY(-1px) scale(0.99);
    box-shadow: var(--shadow-md) !important;
    cursor: grabbing;
}

/* ==========================================================================
   RESPONSIVE DESIGN ADAPTATIONS
   ========================================================================== */

@media (max-width: 768px) {

    /* --- Layout Transformation --- */
    #app {
        flex-direction: column;
    }

    /* Convert Sidebar to Bottom Navigation */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100% !important;
        /* Override variable */
        height: 60px;
        flex-direction: row;
        justify-content: space-around;
        padding-top: 0;
        border-right: none;
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 5000;
        background-color: var(--color-secondary);
        /* Ensure opaque background */
    }

    /* Disable hover expansion on mobile */
    .sidebar:hover,
    .sidebar.expanded {
        width: 100% !important;
        align-items: center;
        /* Keep centered */
    }

    .sidebar-item {
        flex-direction: column;
        justify-content: center;
        height: 100%;
        padding: 4px 0 !important;
        flex: 1;
    }

    .sidebar-item i {
        width: auto;
        min-width: 0;
        margin: 0 !important;
        font-size: 20px;
        height: 24px;
        margin-bottom: 2px !important;
    }

    .sidebar-item span {
        opacity: 1 !important;
        width: auto !important;
        font-size: 10px;
        line-height: 1;
        display: block !important;
        margin-left: 0 !important;
    }

    /* Adjust Main Content to not be hidden behind bottom nav */
    .main-content {
        padding-bottom: 70px;
        /* 60px nav + 10px buffer */
    }

    /* Header / Top Bar */
    .top-bar {
        padding: 0 14px;
        gap: 10px;
    }

    .top-bar-logo {
        height: 30px;
    }

    .page-title {
        font-size: 15px;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .top-bar-actions .btn span {
        display: none;
    }

    .top-bar-actions .btn {
        padding: 8px 10px;
    }

    /* Hide Theme Selector on Mobile to save space */
    .theme-selector-pill {
        display: none !important;
    }

    /* Adjust Search Bar Position */
    #header-search-container {
        top: 60px !important;
        /* Push below header */
        width: 92% !important;
        /* Almost full width */
        max-width: none !important;
    }

    /* New Deal Button (FAB) - Simplify text */
    #fab-action {
        padding: 8px 12px;
    }

    #fab-action i {
        margin-right: 0 !important;
    }

    #fab-action {
        font-size: 0;
        /* Hide text */
    }

    #fab-action i {
        font-size: 16px;
        /* Show icon */
    }

    /* --- Views & Components --- */
    .view-container {
        padding: 16px;
        /* Reduce padding */
    }

    /* Modals - Full width/BottomSheet style */
    .modal {
        width: 95% !important;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Kanban Board */
    .kanban-board {
        padding-bottom: 0;
        /* Let main content padding handle it */
    }

    .kanban-column {
        min-width: 85vw;
        /* Almost full screen width per column for focus */
        max-width: 85vw;
    }

    /* Deal Details - 3 Column Layout to Stack */
    .grid-3-col {
        grid-template-columns: 1fr !important;
    }

    /* Settings Page */
    .settings-layout {
        flex-direction: column !important;
    }

    .settings-sidebar {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--color-border);
        margin-bottom: 16px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {

    /* Tablet Tweaks */
    .kanban-column {
        min-width: 200px;
        /* Slightly narrower columns */
    }

    .theme-label {
        display: none;
    }
}
}

/* ==========================================================================
   GLOBAL MOBILE FIXES (Settings, Tables, Forms)
   ========================================================================== */
@media (max-width: 768px) {

    /* --- General Form Elements --- */
    .form-group,
    .row {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .form-input,
    .form-select,
    textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* --- Buttons --- */
    /* Make buttons distinct and easy to tap, but allow them to be inline if they are small icons */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 4px;
        justify-content: center;
    }

    /* --- Settings View --- */
    /* Scrollable Tab Bar */
    .card>div:first-child {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 8px;
        margin-bottom: 16px;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
        /* Hide scrollbar for cleaner look */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .card>div:first-child::-webkit-scrollbar {
        display: none;
    }

    .card>div:first-child .btn {
        display: inline-block;
        width: auto;
        /* Buttons in tabs should auto-size */
        margin-right: 8px;
        margin-bottom: 0;
    }

    /* Stack 'Integrations' and 'Backup' cards */
    .settings-content .card {
        min-width: 0 !important;
        width: 100% !important;
        margin: 0 0 16px 0 !important;
    }

    #settings-content>div {
        /* Flex container for Backup cards */
        flex-direction: column !important;
    }

    /* --- Tables (Contacts, Tasks) --- */
    /* Force tables to be scrollable containers avoiding layout break */
    .task-list,
    .spreadsheet-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure rows don't wrap weirdly inside the scroll */
    .task-list tbody,
    .spreadsheet-table tbody {
        display: table;
        width: 100%;
    }

    /* Tasks Filter Bar */
    .spreadsheet-container {
        height: auto !important;
        /* Allow page scroll instead of inner scroll */
        max-height: 70vh;
    }

    /* Reset Filter bar layout */
    .spreadsheet-container+div>div:first-child,
    /* This selector might be wrong based on structure, targeting generic flex filter bars */
    [style*='display:flex; gap: 12px; flex-wrap:wrap'] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #filter-start,
    #filter-end,
    #filter-priority,
    #filter-status {
        width: 100% !important;
    }
}

/* Pipeline Progress Bar (Deal Details) */
.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    cursor: pointer;
    background: transparent;
    padding: 0 4px;
}

.pipeline-step:hover .pipeline-dot {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(0, 156, 99, 0.1);
}

.pipeline-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #e0e0e0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 4px;
}

.pipeline-label {
    font-size: 10px;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s;
    text-align: center;
    white-space: nowrap;
}

/* Active State */
.pipeline-step.active .pipeline-dot {
    background: #fff;
    border-color: var(--color-primary);
    /* Green */
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(0, 156, 99, 0.2);
}

.pipeline-step.active .pipeline-label {
    color: var(--color-primary);
    font-weight: 800;
}

/* Completed State */
.pipeline-step.completed .pipeline-dot {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.pipeline-step.completed .pipeline-label {
    color: var(--color-primary);
}

/* Force Task Checkbox to be Green */
.task-check,
.task-check i,
.task-check.completed,
.task-check.completed i {
    color: #28a745 !important;
}