/* ==========================================================================
   ULTIMATE BUDDY — Shared Styles
   Brand design tokens, fonts, layout utilities, and Tailwind replacements.
   This file is included by every page in the app.
   ========================================================================== */

/* --- Auth Gate: hide page until authenticated --- */
html:not(.authenticated) { display: none !important; }

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Onest:wght@400;500;700;800&display=swap');

/* --- Feature Flag: hide gated elements until features.js resolves --- */
[data-feature] { visibility: hidden; }
[data-feature].feature-hidden { display: none !important; }

/* --- Brand Design Tokens --- */
:root {
    --primary-green: #00c42a;
    --active-green: #acff54;
    --light-green: #d8fdd2;
    --text-dark: #2d2d2d;
    --bg-light-grey: #f2f2f2;
    --border-grey: #e0e0e0;
    --white: #ffffff;
    --font-primary: 'Onest', 'Inter', sans-serif;
    --font-secondary: 'Inter', Arial, sans-serif;
    --text-secondary: #555;
    --text-muted: #999;
    --shadow-color: rgba(0,0,0,0.08);
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --primary-green: #00d43a;
    --active-green: #acff54;
    --light-green: #1a3a1a;
    --text-dark: #e8e8e8;
    --bg-light-grey: #1a1a1a;
    --border-grey: #333;
    --white: #242424;
    --text-secondary: #aaa;
    --text-muted: #666;
    --shadow-color: rgba(0,0,0,0.4);
    color-scheme: dark;
}

/* --- Base Reset --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-primary);
    background-color: var(--bg-light-grey);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   APP SHELL — Sidebar + Content Area
   ========================================================================== */

#app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
#app-sidebar {
    width: 240px;
    min-width: 240px;
    background-color: var(--white);
    border-right: 1px solid var(--border-grey);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

#app-sidebar.collapsed {
    width: 60px;
    min-width: 60px;
}

#app-sidebar.collapsed .nav-label,
#app-sidebar.collapsed .nav-section-title,
#app-sidebar.collapsed .sidebar-header-text,
#app-sidebar.collapsed .sidebar-logo {
    display: none;
}

#app-sidebar.collapsed .sidebar-header {
    justify-content: center;
}

#app-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

#app-sidebar.collapsed .nav-icon {
    margin-right: 0;
}

/* Content area */
#app-content {
    flex: 1;
    margin-left: 240px;
    transition: margin-left 0.25s ease;
    min-width: 0;
}

#app-sidebar.collapsed ~ #app-content,
.sidebar-collapsed #app-content {
    margin-left: 60px;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-grey);
    gap: 0.75rem;
    min-height: 64px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    min-width: 32px;
    object-fit: contain;
}

.sidebar-header-text {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-dark);
    white-space: nowrap;
}

/* Sidebar Toggle */
.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 1.25rem;
    flex-shrink: 0;
    border-radius: 6px;
    transition: background 0.15s;
}

.sidebar-toggle:hover {
    background: var(--bg-light-grey);
    color: var(--text-dark);
}

/* Navigation Links */
.nav-section {
    padding: 0.5rem 0;
}

.nav-section-title {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    margin: 2px 8px;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: var(--bg-light-grey);
    color: var(--text-dark);
}

.nav-link.active {
    background-color: var(--light-green);
    color: var(--primary-green);
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    flex-shrink: 0;
    text-align: center;
    font-size: 1rem;
    line-height: 20px;
}

.nav-label {
    white-space: nowrap;
}

.nav-external-icon {
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.4;
}

/* Mobile Hamburger */
#mobile-hamburger {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    background: var(--white);
    border: 1px solid var(--border-grey);
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-size: 1.3rem;
    line-height: 1;
}

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 90;
}

@media (max-width: 768px) {
    #mobile-hamburger { display: block; }

    #app-sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }

    #app-sidebar.mobile-open {
        transform: translateX(0);
        width: 240px;
        min-width: 240px;
    }

    #app-sidebar.mobile-open .nav-label,
    #app-sidebar.mobile-open .nav-section-title,
    #app-sidebar.mobile-open .sidebar-header-text {
        display: unset;
    }

    #app-sidebar.mobile-open .nav-link {
        justify-content: flex-start;
        padding: 0.6rem 1rem;
    }

    #app-sidebar.mobile-open .nav-icon {
        margin-right: 0.75rem;
    }

    #sidebar-overlay.visible { display: block; }

    #app-content { margin-left: 0 !important; padding-top: 3.5rem; }
}


/* ==========================================================================
   TAILWIND REPLACEMENT UTILITIES
   Converted from Sales Buddy's Tailwind classes to plain CSS.
   ========================================================================== */

/* Display & Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.min-h-screen { min-height: 100vh; }

/* Gap */
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-6 { gap: 1.5rem; }

/* Width */
.w-full { width: 100%; }
.w-8 { width: 2rem; }
.h-8 { height: 2rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-7xl { max-width: 80rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-4 { padding-bottom: 1rem; }

/* Margin */
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mb-12 { margin-bottom: 3rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.my-8 { margin-top: 2rem; margin-bottom: 2rem; }

/* Typography */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-5xl { font-size: 3rem; line-height: 1; }
.text-6xl { font-size: 3.75rem; line-height: 1; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }
.text-center { text-align: center; }

/* Colors */
.bg-brand-primary { background-color: var(--primary-green); }
.bg-brand-active { background-color: var(--active-green); }
.bg-brand-light-green { background-color: var(--light-green); }
.bg-white { background-color: var(--white); }
.bg-gray-200 { background-color: #e5e7eb; }
.text-brand-primary { color: var(--primary-green); }
.text-brand-black { color: var(--text-dark); }
.text-white { color: white; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-yellow-700 { color: #a16207; }
.text-red-500 { color: #ef4444; }
.text-green-700 { color: #15803d; }
.text-blue-600 { color: #2563eb; }

/* Borders */
.border { border: 1px solid var(--border-grey); }
.border-2 { border-width: 2px; }
.border-b { border-bottom: 1px solid var(--border-grey); }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-transparent { border-color: transparent; }

/* Radius */
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }

/* Shadow */
.shadow-sm { box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1); }

/* Transitions */
.transition { transition: all 0.15s ease; }
.transition-all { transition: all 0.15s ease; }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
.transition-transform { transition: transform 0.15s ease; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }
.duration-500 { transition-duration: 500ms; }

/* Transform */
.transform { will-change: transform; }
.hover\:scale-105:hover { transform: scale(1.05); }
.hover\:-translate-y-1:hover { transform: translateY(-0.25rem); }
.active\:scale-95:active { transform: scale(0.95); }

/* Focus */
.outline-none { outline: none; }
.focus\:ring-2:focus { box-shadow: 0 0 0 2px var(--active-green); }
.focus\:border-transparent:focus { border-color: transparent; }

/* Hover */
.hover\:bg-gray-300:hover { background-color: #d1d5db; }
.hover\:bg-brand-active:hover { background-color: var(--active-green); color: var(--text-dark); }
.hover\:shadow-xl:hover { box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1); }
.hover\:border-brand-green:hover { border-color: var(--primary-green); }
.hover\:underline:hover { text-decoration: underline; }

/* Spacing utilities */
.space-y-2 > * + * { margin-top: 0.5rem; }

/* Lists */
.list-disc { list-style-type: disc; }
.list-inside { list-style-position: inside; }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }
.opacity-25 { opacity: 0.25; }
.opacity-75 { opacity: 0.75; }

/* Responsive */
@media (min-width: 640px) {
    .sm\:flex-row { flex-direction: row; }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 768px) {
    .md\:text-6xl { font-size: 3.75rem; line-height: 1; }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .md\:block { display: block; }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
}

/* Grid for dashboard cards */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }

/* Min-height utility */
.min-h-\[300px\] { min-height: 300px; }

/* Font families */
.font-primary { font-family: var(--font-primary); }
.font-secondary { font-family: var(--font-secondary); }


/* ==========================================================================
   SHARED COMPONENT STYLES
   Toast notifications, buttons, common patterns
   ========================================================================== */

/* Toast Notification */
#toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    font-size: 17px;
    opacity: 0;
    transition: opacity 0.3s;
}
#toast.show { visibility: visible; opacity: 1; }

/* Common Two-Column Tool Layout (used by Quote, Email, Welcome Buddy) */
.tool-container {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 500px 1fr;
    gap: 2rem;
    padding: 2rem;
}

@media (max-width: 1300px) {
    .tool-container { grid-template-columns: 1fr; }
    .tool-container .input-panel,
    .tool-container .preview-panel-container {
        position: static;
        max-height: none;
        height: auto;
        overflow: visible;
    }
}

/* Sticky header for non-sidebar pages */
.sticky-top-0 { position: sticky; top: 0; z-index: 40; }

/* Accessible focus styles */
:focus-visible {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
}

/* ==========================================================================
   SIDEBAR FOOTER — User Info & Sign Out
   ========================================================================== */

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-grey);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-user-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout-btn {
    background: none;
    border: 1px solid var(--border-grey);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-family: var(--font-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.sidebar-logout-btn:hover {
    background-color: var(--bg-light-grey);
    color: var(--text-dark);
    border-color: #bbb;
}

/* Hide user info and logout when sidebar is collapsed */
#app-sidebar.collapsed .sidebar-footer {
    padding: 0.5rem;
    align-items: center;
}

#app-sidebar.collapsed .sidebar-user-name,
#app-sidebar.collapsed .sidebar-logout-btn {
    display: none;
}

/* Show full footer when sidebar opens on mobile */
#app-sidebar.mobile-open .sidebar-user-name,
#app-sidebar.mobile-open .sidebar-logout-btn {
    display: unset;
}

#app-sidebar.mobile-open .sidebar-footer {
    padding: 0.75rem 1rem;
    align-items: stretch;
}

/* ==========================================================================
   DARK MODE — Theme Toggle & Overrides
   ========================================================================== */

.sidebar-theme-toggle {
    background: none;
    border: 1px solid var(--border-grey);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    margin: 0 0.75rem 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-theme-toggle:hover {
    background-color: var(--bg-light-grey);
    color: var(--text-dark);
    border-color: var(--text-muted);
}

.sidebar-theme-toggle .theme-icon { font-size: 0.9rem; }

/* Show sun icon in dark mode, moon icon in light mode */
[data-theme="dark"] .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-icon-dark { display: none; }
.theme-icon-light { display: none; }
.theme-icon-dark { display: inline; }

#app-sidebar.collapsed .sidebar-theme-toggle .theme-label { display: none; }

/* Dark mode toast inversion */
[data-theme="dark"] #toast {
    background-color: #e8e8e8;
    color: #1a1a1a;
}

/* Dark mode input overrides */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: #2e2e2e;
    color: #e8e8e8;
    border-color: var(--border-grey);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #666;
}

/* Dark mode — force quote preview to always stay in light mode */
[data-theme="dark"] .preview-panel-container .preview-page {
    background-color: #ffffff;
    --white: #ffffff;
    --text-dark: #2d2d2d;
    --primary-green: #00c42a;
    --border-grey: #e0e0e0;
    --bg-light-grey: #f5f5f5;
    --light-green: #e6f9ec;
    color: #2d2d2d;
}

/* Dark mode — generic modal/overlay backgrounds */
[data-theme="dark"] .esign-modal,
[data-theme="dark"] .modal-content {
    background-color: #2e2e2e;
    color: #e8e8e8;
}
[data-theme="dark"] .esign-modal h3,
[data-theme="dark"] .modal-header h2 {
    color: #e8e8e8;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: #444;
}

/* Dark mode — checkbox groups / offers */
[data-theme="dark"] .checkbox-group {
    background: #2e2e2e;
    color: #e8e8e8;
}
[data-theme="dark"] .checkbox-group label {
    color: #e8e8e8;
}

/* Dark mode — form labels and text */
[data-theme="dark"] .form-group label {
    color: #ccc;
}
[data-theme="dark"] .form-hint {
    color: #888;
}

/* Dark mode — buttons with hardcoded dark backgrounds */
[data-theme="dark"] .btn-outline {
    background: #2e2e2e;
    color: #e8e8e8;
    border-color: #555;
}
[data-theme="dark"] .btn-outline:hover {
    border-color: var(--primary-green);
    color: var(--primary-green);
}

/* Dark mode — project buddy cards and dropdowns */
[data-theme="dark"] .project-card,
[data-theme="dark"] .kanban-card,
[data-theme="dark"] .issue-panel,
[data-theme="dark"] .board-header,
[data-theme="dark"] .list-table thead {
    background: #2e2e2e;
    color: #e8e8e8;
}
[data-theme="dark"] .project-card {
    border-color: #444;
}
[data-theme="dark"] .project-name,
[data-theme="dark"] .board-title,
[data-theme="dark"] .card-title,
[data-theme="dark"] .panel-title-input,
[data-theme="dark"] .comment-author,
[data-theme="dark"] .desc-label,
[data-theme="dark"] .state-name,
[data-theme="dark"] .list-row-title,
[data-theme="dark"] .vis-title {
    color: #e8e8e8;
}
[data-theme="dark"] .project-desc,
[data-theme="dark"] .prop-label,
[data-theme="dark"] .activity-item,
[data-theme="dark"] .back-btn,
[data-theme="dark"] .board-settings-btn,
[data-theme="dark"] .filter-clear,
[data-theme="dark"] .panel-tab,
[data-theme="dark"] .desc-toggle,
[data-theme="dark"] .vis-desc {
    color: #aaa;
}
[data-theme="dark"] .project-meta,
[data-theme="dark"] .project-id,
[data-theme="dark"] .card-id,
[data-theme="dark"] .card-due,
[data-theme="dark"] .panel-id,
[data-theme="dark"] .comment-time,
[data-theme="dark"] .sub-issue-id,
[data-theme="dark"] .sub-issue-progress-text,
[data-theme="dark"] .state-count,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .loading-spinner {
    color: #888;
}

/* Dark mode — kanban column background */
[data-theme="dark"] .kanban-column {
    background: #1f1f1f;
}
[data-theme="dark"] .kanban-card {
    border-color: #444;
}

/* Dark mode — table rows */
[data-theme="dark"] .list-table th {
    color: #aaa;
    border-bottom-color: #444;
}
[data-theme="dark"] .list-table td {
    border-bottom-color: #333;
    color: #e8e8e8;
}
[data-theme="dark"] .list-table tbody tr:hover {
    background: #333;
}
[data-theme="dark"] .list-table tbody tr:nth-child(even) {
    background: #262626;
}
[data-theme="dark"] .list-table tbody tr:nth-child(even):hover {
    background: #333;
}

/* Dark mode — list view selects */
[data-theme="dark"] .list-inline-select {
    color: #e8e8e8;
}
[data-theme="dark"] .list-inline-select:hover,
[data-theme="dark"] .list-inline-select:focus {
    background: #2e2e2e;
}

/* Dark mode — dropdowns and panels */
[data-theme="dark"] .menu-dropdown,
[data-theme="dark"] .multi-select-list,
[data-theme="dark"] .views-menu {
    background: #2e2e2e;
    border-color: #444;
}
[data-theme="dark"] .menu-item,
[data-theme="dark"] .multi-select-item,
[data-theme="dark"] .views-menu-item {
    color: #e8e8e8;
}
[data-theme="dark"] .menu-item:hover,
[data-theme="dark"] .multi-select-item:hover,
[data-theme="dark"] .views-menu-item:hover {
    background: #3a3a3a;
}
[data-theme="dark"] .menu-btn:hover,
[data-theme="dark"] .back-btn:hover {
    background: #3a3a3a;
    color: #e8e8e8;
}

/* Dark mode — panel detail */
[data-theme="dark"] .panel-header,
[data-theme="dark"] .panel-tabs,
[data-theme="dark"] .comment-item,
[data-theme="dark"] .sub-issue-item {
    border-color: #444;
}
[data-theme="dark"] .panel-title-input {
    background: transparent;
}
[data-theme="dark"] .multi-select-trigger,
[data-theme="dark"] .multi-select-chip {
    background: #3a3a3a;
    color: #e8e8e8;
}
[data-theme="dark"] .desc-preview {
    border-color: #444;
    color: #e8e8e8;
}
[data-theme="dark"] .desc-preview code {
    background: #3a3a3a;
}
[data-theme="dark"] .desc-preview pre {
    background: #3a3a3a;
}
[data-theme="dark"] .sub-issue-item:hover {
    background: #3a3a3a;
}
[data-theme="dark"] .parent-breadcrumb {
    background: #333;
    color: #aaa;
}

/* Dark mode — view toggle */
[data-theme="dark"] .view-toggle-btn {
    background: #2e2e2e;
    color: #aaa;
}
[data-theme="dark"] .view-toggle-btn:hover:not(.active) {
    background: #3a3a3a;
}
[data-theme="dark"] .views-trigger {
    background: #2e2e2e;
    color: #e8e8e8;
}

/* Dark mode — filter selects */
[data-theme="dark"] .filter-select,
[data-theme="dark"] .filter-search {
    background: #2e2e2e;
    color: #e8e8e8;
    border-color: #444;
}

/* Dark mode — vis cards (project visibility) */
[data-theme="dark"] .vis-card {
    border-color: #444;
    background: #2e2e2e;
}
[data-theme="dark"] .vis-card:hover {
    border-color: #888;
}
[data-theme="dark"] .vis-card.active {
    border-color: var(--primary-green);
    background: rgba(0,212,58,0.08);
}

/* Dark mode — quick add inputs */
[data-theme="dark"] .quick-add input {
    background: #2e2e2e;
    color: #e8e8e8;
}

/* Dark mode — list state/priority badges */
[data-theme="dark"] .list-state-badge {
    background: #3a3a3a;
    color: #e8e8e8;
}

/* Dark mode — card avatar border */
[data-theme="dark"] .card-avatar {
    border-color: #2e2e2e;
}

/* Dark mode — empty column */
[data-theme="dark"] .empty-column {
    color: #666;
}

/* Dark mode — pipeline buddy insights button fix */
[data-theme="dark"] .pipe-btn-ai {
    background-color: #333;
    color: var(--active-green);
    border-color: #555;
}
[data-theme="dark"] .pipe-btn-ai:hover {
    background-color: #444;
    color: #fff;
}

/* Dark mode — pipeline header & controls */
[data-theme="dark"] .pipeline-header {
    background-color: #2e2e2e;
}
[data-theme="dark"] .pipe-btn {
    background-color: #2e2e2e;
    border-color: #555;
}

/* ============================================================ */
/* Notes panel (shared/notes.js)                                 */
/* Used inside the Lead modal (lead-crm.html), the Opp modal     */
/* (opportunity-buddy.html), and styled here so both inherit.    */
/* Mobile gets its own override block in mobile/css/mobile.css.  */
/* ============================================================ */
.notes-panel { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.notes-add { display: flex; flex-direction: column; gap: 0.5rem; }
.notes-add-text {
    width: 100%; resize: vertical; min-height: 60px;
    padding: 0.55rem 0.7rem;
    font-family: inherit; font-size: 0.88rem; line-height: 1.45;
    border: 1px solid #d1d5db; border-radius: 0.5rem;
    background: #ffffff; color: #1a1a1a; box-sizing: border-box;
}
.notes-add-text:focus { outline: none; border-color: #00c42a; box-shadow: 0 0 0 2px rgba(0,196,42,0.15); }
.notes-add-btn {
    align-self: flex-end; padding: 0.45rem 0.95rem;
    background: #00c42a; color: #fff; border: 0; border-radius: 0.5rem;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.notes-add-btn:hover { background: #00a423; }
.notes-add-btn:disabled { opacity: 0.55; cursor: wait; }

.notes-list { display: flex; flex-direction: column; gap: 0.55rem; }
.notes-empty { font-size: 0.82rem; color: #6b7280; padding: 0.5rem 0; }
.notes-error {
    font-size: 0.82rem; color: #b91c1c;
    background: #fef2f2; border: 1px solid #fecaca; border-radius: 0.4rem;
    padding: 0.45rem 0.7rem;
}

.notes-item {
    background: #fafafa; border: 1px solid #e5e7eb; border-radius: 0.5rem;
    padding: 0.65rem 0.8rem;
}
.notes-body {
    font-size: 0.88rem; line-height: 1.5; color: #1f2937;
    white-space: pre-wrap; word-break: break-word;
    margin-bottom: 0.4rem;
}
.notes-body-edit-textarea {
    width: 100%; min-height: 60px; resize: vertical;
    padding: 0.5rem 0.65rem;
    font-family: inherit; font-size: 0.88rem; line-height: 1.45;
    border: 1px solid #00c42a; border-radius: 0.4rem;
    background: #ffffff; color: #1a1a1a; box-sizing: border-box;
}
.notes-body-edit-textarea:focus { outline: none; box-shadow: 0 0 0 2px rgba(0,196,42,0.15); }
.notes-footer {
    display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap;
    font-size: 0.74rem; color: #6b7280;
}
.notes-author { font-weight: 600; color: #4b5563; }
.notes-time { color: #9ca3af; }
.notes-actions { display: inline-flex; gap: 0.4rem; margin-left: auto; }
.notes-edit, .notes-delete, .notes-save, .notes-cancel {
    background: transparent; border: 1px solid #d1d5db; color: #4b5563;
    padding: 0.18rem 0.55rem; border-radius: 0.35rem;
    font-size: 0.72rem; font-weight: 500; cursor: pointer; line-height: 1.4;
}
.notes-edit:hover, .notes-cancel:hover { background: #f3f4f6; }
.notes-delete { color: #b91c1c; border-color: #fecaca; }
.notes-delete:hover { background: #fef2f2; }
.notes-save { background: #00c42a; color: #fff; border-color: #00c42a; }
.notes-save:hover { background: #00a423; }

/* Dark mode */
[data-theme="dark"] .notes-add-text,
[data-theme="dark"] .notes-body-edit-textarea {
    background: #1e1e1e; color: #e8e8e8; border-color: #444;
}
[data-theme="dark"] .notes-item { background: #2a2a2a; border-color: #3a3a3a; }
[data-theme="dark"] .notes-body { color: #e8e8e8; }
[data-theme="dark"] .notes-author { color: #d1d5db; }
[data-theme="dark"] .notes-time { color: #888; }
[data-theme="dark"] .notes-empty { color: #888; }
[data-theme="dark"] .notes-error { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .notes-edit, [data-theme="dark"] .notes-cancel {
    background: transparent; color: #d1d5db; border-color: #555;
}
[data-theme="dark"] .notes-edit:hover, [data-theme="dark"] .notes-cancel:hover {
    background: #333;
}
[data-theme="dark"] .notes-delete { color: #ef5350; border-color: #7f1d1d; }
[data-theme="dark"] .notes-delete:hover { background: #450a0a; }
