:root {
    /* Pipedrive-inspired palette */
    --color-primary: #009c63;
    /* Green */
    --color-primary-dark: #007a4d;
    --color-secondary: #26292c;
    /* Dark Sidebar */
    --color-bg: #f4f5f7;
    /* Light Gray Canvas */
    --color-surface: #ffffff;
    --color-text-main: #131517;
    --color-text-secondary: #747678;
    --color-border: #dfe1e6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --header-height: 56px;
    --sidebar-width: 36px;
    /* Ultra narrow as requested */
    /* Collapsed width style */
    --sidebar-width-expanded: 240px;

    /* Font Variable - Default to Inter */
    --font-family-body: 'Inter', sans-serif;
}

/* 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"] {
    --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) */
/* Bg (#000) < Card (#111) <<< Surface (#333) */
[data-theme="midnight-neon"] {
    --color-primary: #3b82f6;
    --color-bg: #000000;
    /* Pure Black */
    --color-card: #111111;
    /* Near Black Card */
    --color-surface: #383838;
    /* Distinct Dark Gray Column */
    --color-border: #4d4d4d;
    --glow-color: rgba(59, 130, 246, 0.2);
}

/* 2. Nordic Night (Blue-Grey) */
/* Bg (#1a1e24) < Card (#242933) <<< Surface (#434c5e) */
[data-theme="cyber-glass"] {
    --color-primary: #88c0d0;
    --color-bg: #1a1e24;
    /* Deepest */
    --color-card: #242933;
    /* Nordic Black-Blue */
    --color-surface: #434c5e;
    /* Nordic Polar Night 2 (Much Lighter) */
    --color-border: #4c566a;
    --glow-color: rgba(136, 192, 208, 0.3);
}

/* 3. Vintage Warm (Gruvbox) */
/* Bg (#101010) < Card (#1d2021) <<< Surface (#504945) */
[data-theme="dark-luxe"] {
    --color-primary: #d79921;
    --color-bg: #101010;
    --color-card: #1d2021;
    /* Hard Gruvbox Dark */
    --color-surface: #504945;
    /* Distinct Brown-Gray */
    --color-border: #665c54;
    --glow-color: rgba(215, 153, 33, 0.2);
}

/* 4. Deep Forest (Green) */
/* Bg (#01150f) < Card (#032018) <<< Surface (#064e3b) */
[data-theme="aurora-borealis"] {
    --color-primary: #10b981;
    --color-bg: #01150f;
    --color-card: #032018;
    /* Deepest Green */
    --color-surface: #064e3b;
    /* Visible Green Surface */
    --color-border: #047857;
    --glow-color: rgba(16, 185, 129, 0.2);
}

/* 5. Vampire Classic (Red) */
/* Bg (#0a0000) < Card (#1a0303) <<< Surface (#450a0a) */
[data-theme="crimson-night"] {
    --color-primary: #ef4444;
    --color-bg: #0a0000;
    --color-card: #1a0303;
    /* Near Black Red */
    --color-surface: #450a0a;
    /* Visible Deep Red */
    --color-border: #7f1d1d;
    --glow-color: rgba(239, 68, 68, 0.3);
}

/* 6. Matrix Code (Green/Black) */
/* Bg (#000) < Card (#080808) <<< Surface (#1f1f1f) */
[data-theme="toxic-protocol"] {
    --color-primary: #84cc16;
    --color-bg: #000000;
    --color-card: #080808;
    /* Almost Black */
    --color-surface: #1f1f1f;
    /* Dark Gray */
    --color-border: #333333;
    --glow-color: rgba(132, 204, 22, 0.2);
}

/* 7. Cyberpunk Purple */
/* Bg (#0a0314) < Card (#150524) <<< Surface (#3b0764) */
[data-theme="royal-amethyst"] {
    --color-primary: #d946ef;
    --color-bg: #0a0314;
    --color-card: #150524;
    /* Deepest Purple */
    --color-surface: #3b0764;
    /* Visible Purple */
    --color-border: #581c87;
    --glow-color: rgba(217, 70, 239, 0.3);
}

/* 8. Navy Vintage */
/* Bg (#020617) < Card (#0b1120) <<< Surface (#1e293b) */
[data-theme="oceanic-depth"] {
    --color-primary: #3b82f6;
    --color-bg: #020617;
    /* Slate 950 */
    --color-card: #0b1120;
    /* Almost Black Blue */
    --color-surface: #1e293b;
    /* Slate 800 - Visible */
    --color-border: #334155;
    --glow-color: rgba(59, 130, 246, 0.2);
}

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

/* 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);
}


/* ... existing themes ... */

/* ... existing themes ... */

* {
    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.5;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-secondary);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    transition: width 0.3s ease;
    z-index: 2000;
    overflow: hidden;
    /* Vital: Hides text when collapsed */
}

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

.sidebar-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    /* No padding in collapsed state */
    height: 48px;
    /* Fixed height for touch target */
    justify-content: flex-start;
    /* Reset to start, but icon handles centering */
    color: #b0b3b5;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, background-color 0.2s;
    overflow: hidden;
    /* Ensure nothing leaks */
}

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

.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;
}

/* 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;
}

/* Header */
.top-bar {
    height: var(--header-height);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    position: relative;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
}

/* View Area */
.view-container {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

/* Components: Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background-color: var(--color-primary-dark);
}

/* 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: 16px;
    height: 100%;
    overflow-x: auto;
    padding-bottom: 16px;
}

.kanban-column {
    min-width: 250px;
    /* max-width: 280px; Removed to allow auto-fit */
    flex: 1 0 auto;
    /* Grow, Don't Shrink, Auto Basis - Forces scroll if too many */
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kanban-header {
    padding: 12px 4px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.kanban-column:nth-child(1) .kanban-header {
    border-color: #ddd;
}

/* Default */

.kanban-cards {
    flex: 1 1 auto;
    /* Allow grow/shrink */
    overflow-y: visible;
    padding: 4px;
    min-height: 0;
    /* Crucial for nested flex scrolling */
    /* For drag shadow visibility */
    --card-font-base: 14px;
    /* Default base size */
}

.deal-card {
    background: var(--color-card) !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0;
    /* Content handles padding */
    margin-bottom: 4px;
    cursor: grab;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 5px solid var(--color-primary);
    /* Theme colored border */
    display: flex;
    flex-direction: column;
    height: auto;
    /* Allow growth */
    min-height: min-content;
    /* Ensure it fits content */
    overflow: visible;
    /* Don't hide content */
    /* Font Scaling Base */
    font-size: var(--card-font-base);
    /* Ensure content wraps */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.deal-card:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    transform: 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);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* 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;
}

.custom-modal {
    background: var(--color-surface);
    width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.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: 16px;
}

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

.form-input,
.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* 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: 6px 12px;
    border-radius: 50px;
    gap: 8px;
    border: 1px solid #e0e0e0;
}

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

.theme-dot {
    width: 20px;
    height: 20px;
    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;
}

/* 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 3D Shadow Effects */
/* ============================================================ */
.deal-card {
    background: var(--color-surface);
    border-radius: 20px 0 20px 0 !important;
    border: 1px solid var(--color-border) !important;
    box-shadow:
        2px 4px 12px rgba(0, 0, 0, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    transition: all 0.2s ease-out !important;
    cursor: pointer;
}

.deal-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        4px 8px 20px rgba(0, 0, 0, 0.18),
        0 4px 8px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
}

.deal-card:active {
    transform: translateY(-2px) scale(1.005);
    box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* ==========================================================================
   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 16px;
        justify-content: space-between;
    }

    #app-logo {
        height: 32px !important;
        margin-right: 8px !important;
    }

    .page-title {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }

    /* 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;
        /* Save space */
    }
}
}

/* ==========================================================================
   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;
}