/* Mini CRM - Modern SaaS UI Stylesheet */
/* TailwindCSS + Bootstrap 5 + Custom Styles */

:root {
    --brand-primary: #2563eb;
    --brand-secondary: #6c757d;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --sidebar-bg: #111827;
    --sidebar-hover: #1f2937;
    --sidebar-active: #2563eb;
    --sidebar-text: #9ca3af;
    --sidebar-text-active: #ffffff;
    --topbar-height: 64px;
    --surface-bg: #f5f7fb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
}

/* ============================================
   BASE
   ============================================ */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--surface-bg);
    color: #111827;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}

.sidebar-expanded {
    width: var(--sidebar-width);
}

.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar text label - hidden when collapsed */
.sidebar-text-label {
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-collapsed .sidebar-text-label {
    opacity: 0;
    width: 0;
    display: none;
}

/* Sidebar Brand */
.sidebar-brand {
    padding: 1rem;
    border-bottom: 1px solid var(--sidebar-hover);
    font-weight: 600;
    font-size: 1rem;
    color: var(--sidebar-text-active);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 64px;
    white-space: nowrap;
}

.sidebar-brand img {
    max-height: 32px;
    max-width: 120px;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    font-size: 1.25rem;
    color: var(--brand-primary);
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.sidebar-logo {
    flex-shrink: 0;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
}

.sidebar-section {
    padding: 0.75rem 1.25rem 0.35rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    gap: 0.75rem;
    white-space: nowrap;
    border-left: 3px solid transparent;
    margin: 2px 0;
    position: relative;
}

.sidebar-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--sidebar-text-active);
    font-weight: 500;
    border-left-color: var(--brand-primary);
}

.sidebar-item .icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--sidebar-hover);
}

.sidebar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    padding: 0.5rem 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.sidebar-user-btn:hover {
    color: var(--sidebar-text-active);
}

.sidebar-user-btn::after {
    display: none !important;
}

.sidebar-user-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.sidebar-user-name {
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed sidebar adjustments */
.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 1rem 0;
}

.sidebar-collapsed .sidebar-item {
    justify-content: center;
    padding: 0.625rem 0;
    border-left: none;
}

.sidebar-collapsed .sidebar-item.active {
    border-left: none;
    position: relative;
}

.sidebar-collapsed .sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 2px;
    width: 16px;
    height: 3px;
    background: var(--brand-primary);
    border-radius: 2px;
}

.sidebar-collapsed .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0;
}

.sidebar-collapsed .sidebar-footer .flex {
    justify-content: center;
}

.sidebar-collapsed .sidebar-user-btn {
    justify-content: center;
    padding: 0.5rem 0;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-toggle-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 1.35rem;
    padding: 0.35rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.topbar-toggle-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.topbar-icon-btn {
    position: relative;
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 1.25rem;
    padding: 0.4rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    text-decoration: none;
}

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

.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.topbar-user-btn:hover {
    background: #f3f4f6;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 0.9rem;
}

.topbar-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    min-height: 100vh;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-content.sidebar-transition {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content-expanded {
    margin-left: var(--sidebar-width);
}

.main-content-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    background: var(--card-bg);
}

.card:hover {
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
}

.card-body {
    padding: 1.25rem;
}

/* ============================================
   TABLES
   ============================================ */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    background: #f9fafb;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.875rem;
    color: #374151;
}

.table-hover tbody tr {
    transition: background-color 0.15s ease;
}

.table-hover tbody tr:hover {
    background-color: #f9fafb;
}

.table-responsive {
    border-radius: 0.75rem;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.3em 0.65em;
    font-size: 0.75rem;
    border-radius: 0.375rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 0.375rem;
}

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

.btn-primary:hover {
    background-color: color-mix(in srgb, var(--brand-primary) 85%, black);
    border-color: color-mix(in srgb, var(--brand-primary) 85%, black);
}

.btn-outline-primary {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-outline-primary:hover {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-outline-secondary {
    color: #6b7280;
    border-color: #d1d5db;
}

.btn-outline-secondary:hover {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #9ca3af;
}

/* ============================================
   FORMS
   ============================================ */
.form-control, .form-select {
    border-radius: 0.5rem;
    border-color: #d1d5db;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}

/* ============================================
   KANBAN
   ============================================ */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    min-height: calc(100vh - 250px);
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    flex: 1;
    background: #f3f4f6;
    border-radius: 0.75rem;
    padding: 0.75rem;
}

.kanban-column-header {
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-column-body {
    flex: 1;
    min-height: 200px;
    padding: 0.25rem 0;
}

.kanban-card {
    background: var(--card-bg);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    border: 1px solid var(--border-color);
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.kanban-card-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: #111827;
}

.kanban-card-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
}

/* ============================================
   TIMELINE
   ============================================ */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-icon {
    position: absolute;
    left: -1.5rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.timeline-content {
    background: var(--card-bg);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
}

/* ============================================
   DASHBOARD STAT CARDS
   ============================================ */
.stat-card {
    padding: 1.25rem;
    border-radius: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ============================================
   FUNNEL
   ============================================ */
.funnel-step {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    color: #ffffff;
    font-weight: 500;
    position: relative;
    font-size: 0.875rem;
}

.funnel-step .count {
    float: right;
    font-weight: 600;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notification-bell {
    position: relative;
    cursor: pointer;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    font-size: 0.6rem;
    padding: 0.15em 0.4em;
    min-width: 16px;
    min-height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-dropdown {
    width: 360px;
    max-height: 400px;
    overflow-y: auto;
}

/* ============================================
   MODAL
   ============================================ */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* ============================================
   DRAG & DROP (SortableJS)
   ============================================ */
.kanban-ghost {
    opacity: 0.35;
    background: #dbeafe;
    border: 2px dashed var(--brand-primary);
    border-radius: 0.5rem;
}

.kanban-chosen {
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.18);
    transform: rotate(1.5deg) scale(1.02);
    cursor: grabbing !important;
}

.kanban-dragging {
    opacity: 0.9;
    cursor: grabbing !important;
}

.kanban-drop-zone {
    background: #eff6ff;
    border: 2px dashed #93c5fd;
    border-radius: 0.75rem;
    min-height: 60px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    min-width: 260px;
    max-width: 380px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    cursor: pointer;
}

.toast-item.toast-out {
    animation: toast-out 0.25s ease forwards;
}

.toast-item.toast-success { background: #16a34a; }
.toast-item.toast-error   { background: #dc2626; }
.toast-item.toast-warning { background: #d97706; }
.toast-item.toast-info    { background: #2563eb; }

.toast-item i {
    font-size: 1rem;
    flex-shrink: 0;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(2rem) scale(0.92); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(2rem) scale(0.92); }
}

/* ============================================
   FORM SUBMIT SPINNER
   ============================================ */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.65s linear infinite;
}

.btn-outline-primary.btn-loading::after,
.btn-outline-secondary.btn-loading::after {
    border-color: rgba(37, 99, 235, 0.3);
    border-top-color: var(--brand-primary);
}

@keyframes btn-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 0.375rem !important;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.875rem;
    padding: 0.35rem 0.75rem;
    transition: all 0.15s ease;
}

.page-link:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}

.page-item.active .page-link {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* ============================================
   NAV TABS
   ============================================ */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
    gap: 0;
}

.nav-tabs .nav-link {
    border: none;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.nav-tabs .nav-link:hover {
    color: #111827;
    border-bottom-color: #d1d5db;
}

.nav-tabs .nav-link.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
    background: transparent;
}

/* ============================================
   HTMX INDICATORS
   ============================================ */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-request.htmx-indicator {
    opacity: 1;
}

/* ============================================
   COLOR PICKER
   ============================================ */
input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    cursor: pointer;
}

/* ============================================
   MARGIN COLORS
   ============================================ */
.margin-positive {
    color: #198754;
}

.margin-warning {
    color: #ffc107;
}

.margin-negative {
    color: #dc3545;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    border-radius: 0.75rem;
    border: none;
    font-size: 0.875rem;
}

/* ============================================
   LIST GROUP
   ============================================ */
.list-group-item {
    border-color: var(--border-color);
    padding: 0.875rem 1rem;
}

.list-group-item:first-child {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

.list-group-item:last-child {
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
}

/* ============================================
   DROPDOWN
   ============================================ */
.dropdown-menu {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    min-width: 200px;
}

.dropdown-item {
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-item i {
    margin-right: 0.5rem;
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    margin: 0.35rem 0;
}

/* Dropdown dark variant (for sidebar) */
.dropdown-menu-dark {
    background: #1f2937;
}

.dropdown-menu-dark .dropdown-item {
    color: #d1d5db;
}

.dropdown-menu-dark .dropdown-item:hover {
    background: #374151;
    color: #ffffff;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.sidebar-mobile-open {
        transform: translateX(0);
    }

    .main-content-expanded,
    .main-content-collapsed {
        margin-left: 0;
    }

    .topbar {
        padding: 0 1rem;
    }

    .content-area {
        padding: 1rem;
    }

    .topbar-user-name {
        display: none;
    }
}

/* ============================================
   ALPINE.JS CLOCK
   ============================================ */
[x-cloak] {
    display: none !important;
}

/* ============================================
   UTILITY OVERRIDES
   ============================================ */
/* Fix Bootstrap dropdown toggle arrow */
.dropdown-toggle::after {
    display: none !important;
}

/* Smooth scrollbar for webkit */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header-title i {
    font-size: 1.1rem;
    color: var(--brand-primary);
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ============================================
   CONTACT CHIPS
   ============================================ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 12px;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s;
}

a.chip:hover { opacity: 0.85; text-decoration: none; }

.chip-blue   { background: #eff6ff; color: #2563eb; border: 1px solid #dbeafe; }
.chip-green  { background: #f0fdf4; color: #16a34a; border: 1px solid #dcfce7; }
.chip-purple { background: #faf5ff; color: #7c3aed; border: 1px solid #ede9fe; }
.chip-orange { background: #fff7ed; color: #ea580c; border: 1px solid #fed7aa; }
.chip-gray   { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }

.chip i { font-size: 0.75rem; }

/* ============================================
   LEAD METRICS (hero card)
   ============================================ */
.lead-metric {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lead-metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.lmi-blue   { background: #eff6ff; color: #2563eb; }
.lmi-green  { background: #f0fdf4; color: #16a34a; }
.lmi-purple { background: #faf5ff; color: #7c3aed; }
.lmi-orange { background: #fff7ed; color: #ea580c; }

.lead-metric-label {
    font-size: 0.72rem;
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lead-metric-value {
    font-size: 0.92rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

/* ============================================
   LEAD AVATAR
   ============================================ */
.lead-avatar {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
    letter-spacing: -1px;
    flex-shrink: 0;
}

/* ============================================
   HERO CARD
   ============================================ */
.hero-card {
    border-radius: 16px !important;
    overflow: hidden;
}

.hero-stage-bar {
    height: 4px;
}

.hero-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 0 -1.25rem 1rem;
}

/* ============================================
   STATUS BADGES
   ============================================ */
.badge-draft     { background: #f3f4f6 !important; color: #6b7280 !important; }
.badge-sent      { background: #eff6ff !important; color: #2563eb !important; }
.badge-approved  { background: #f0fdf4 !important; color: #16a34a !important; }
.badge-signed    { background: #f0fdf4 !important; color: #16a34a !important; }
.badge-paid      { background: #f0fdf4 !important; color: #16a34a !important; }
.badge-rejected  { background: #fef2f2 !important; color: #dc2626 !important; }
.badge-cancelled { background: #fef2f2 !important; color: #dc2626 !important; }
.badge-overdue   { background: #fef2f2 !important; color: #dc2626 !important; }
.badge-pending   { background: #fff7ed !important; color: #ea580c !important; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: #9ca3af;
    text-align: center;
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    opacity: 0.35;
    margin-bottom: 0.75rem;
    display: block;
}

.empty-state .empty-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.empty-state .empty-desc {
    font-size: 0.8rem;
    margin: 0;
}

/* ============================================
   INFO PANEL
   ============================================ */
.info-panel {
    background: #f9fafb;
    border-radius: 12px;
    padding: 1.25rem;
    height: 100%;
}

.info-panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-panel-title i { color: #9ca3af; }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 7px 0;
    border-bottom: 1px solid #f3f4f6;
    gap: 1rem;
}

.info-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    font-size: 0.82rem;
    color: #9ca3af;
    font-weight: 400;
    flex-shrink: 0;
}

.info-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    text-align: right;
}

.info-value a { color: var(--brand-primary); text-decoration: none; }
.info-value a:hover { text-decoration: underline; }

/* ============================================
   NOTES PANEL
   ============================================ */
.notes-panel {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 1.25rem;
}

.notes-panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notes-panel p {
    font-size: 0.875rem;
    color: #78350f;
    line-height: 1.6;
    margin: 0;
}

/* ============================================
   TAB TOOLBAR
   ============================================ */
.tab-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.tab-toolbar-title {
    font-weight: 600;
    font-size: 0.925rem;
    color: #111827;
    margin: 0 0 2px;
}

.tab-toolbar-desc {
    font-size: 0.8rem;
    color: #9ca3af;
    margin: 0;
}

/* ============================================
   INNER TABLE (inside cards/tabs)
   ============================================ */
.inner-table-wrap {
    border: 1px solid #f3f4f6;
    border-radius: 12px;
    overflow: hidden;
}

/* ============================================
   CARD NAV TABS
   ============================================ */
.card-tabs-header {
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    overflow-x: auto;
}

.card-nav .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
    background: none;
    padding: 0.75rem 0.875rem;
    transition: color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-nav .nav-link:hover:not(.active) {
    color: #374151;
    background: #f9fafb;
}

.card-nav .nav-link.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.card-nav .nav-link .tab-count {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 100px;
    font-weight: 600;
}

/* ============================================
   TASK KANBAN COLUMNS
   ============================================ */
.ktask-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    align-items: flex-start;
    min-height: calc(100vh - 260px);
}

.ktask-col {
    min-width: 268px;
    max-width: 268px;
    flex-shrink: 0;
}

.ktask-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.ktask-col-title {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ktask-col-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
}

.ktask-col-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    border-radius: 8px;
    min-height: 80px;
    border: 2px dashed;
    font-size: 0.75rem;
    text-align: center;
    gap: 4px;
}

.ktask-col-empty i { font-size: 1.4rem; }

/* Kanban column color themes */
.kth-overdue  { background: #fef2f2; }
.kth-overdue  .ktask-col-title { color: #dc2626; }

.kth-today    { background: #fff7ed; }
.kth-today    .ktask-col-title { color: #ea580c; }

.kth-week     { background: #fffbeb; }
.kth-week     .ktask-col-title { color: #d97706; }

.kth-nextweek { background: #eff6ff; }
.kth-nextweek .ktask-col-title { color: #2563eb; }

.kth-later    { background: #f5f3ff; }
.kth-later    .ktask-col-title { color: #7c3aed; }

.kth-nodate   { background: #f3f4f6; }
.kth-nodate   .ktask-col-title { color: #6b7280; }

/* Task type badge colors (kbadge-* and task-type-*) */
.kbadge-call,    .task-type-call     { background: #eff6ff; color: #2563eb; }
.kbadge-meeting, .task-type-meeting  { background: #faf5ff; color: #7c3aed; }
.kbadge-email,   .task-type-email    { background: #f0fdf4; color: #16a34a; }
.kbadge-followup,.task-type-followup { background: #fff7ed; color: #ea580c; }
.kbadge-other,   .task-type-other    { background: #f3f4f6; color: #6b7280; }

/* Kanban card toggle (checkbox) */
.kcard-toggle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.kcard-toggle:hover { border-color: #2563eb; background: #eff6ff; }
.kcard-overdue .kcard-toggle { border-color: #ef4444; }

/* View toggle active */
.view-btn-active {
    background: #fff !important;
    color: #111827 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}

/* List view row */
.task-row { border-bottom: 1px solid #f9fafb; }
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #f9fafb; }

/* ============================================
   TASK CARD (in lead detail _task_list)
   ============================================ */
.task-item {
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 12px;
}

.task-item.is-overdue {
    border-color: #fee2e2;
    background: #fff5f5;
}

.task-item.is-done {
    border-color: #f3f4f6;
    background: #f9fafb;
}

.task-toggle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    padding: 0;
}

.task-item.is-overdue .task-toggle { border-color: #ef4444; }
.task-item.is-done .task-toggle { border-color: #16a34a; background: #16a34a; }

.task-title { font-size: 0.9rem; font-weight: 500; color: #111827; }
.task-item.is-done .task-title { text-decoration: line-through; color: #9ca3af; }

.task-meta { font-size: 0.78rem; color: #6b7280; }
.task-item.is-overdue .task-due { color: #ef4444; font-weight: 600; }

/* ============================================
   DASHBOARD STAT CARDS (with icons)
   ============================================ */
.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.sci-blue   { background: #eff6ff; color: #2563eb; }
.sci-green  { background: #f0fdf4; color: #16a34a; }
.sci-orange { background: #fff7ed; color: #ea580c; }
.sci-purple { background: #faf5ff; color: #7c3aed; }

/* ============================================
   FILE DROP ZONE
   ============================================ */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: #fafafa;
    user-select: none;
}
.drop-zone:hover,
.drop-zone.drop-zone--active {
    border-color: #6366f1;
    background: #eef2ff;
}
.drop-zone__icon {
    font-size: 2.5rem;
    color: #9ca3af;
    margin-bottom: .5rem;
    transition: color .2s;
}
.drop-zone:hover .drop-zone__icon,
.drop-zone.drop-zone--active .drop-zone__icon {
    color: #6366f1;
}
.drop-zone__title {
    font-size: .9rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .25rem;
}
.drop-zone__hint {
    font-size: .78rem;
    color: #9ca3af;
}
.drop-zone__preview {
    display: none;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: #f3f4f6;
    border-radius: 8px;
    margin-top: .75rem;
    text-align: left;
}
.drop-zone__preview.visible { display: flex; }
.drop-zone__preview-icon { font-size: 1.75rem; flex-shrink: 0; }
.drop-zone__preview-name {
    font-size: .85rem;
    font-weight: 500;
    color: #111827;
    word-break: break-all;
}
.drop-zone__preview-size { font-size: .75rem; color: #6b7280; }
.drop-zone__preview-remove {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.drop-zone__preview-remove:hover { color: #ef4444; background: #fee2e2; }
.drop-zone-fields {
    margin-top: .75rem;
    padding: .75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    animation: fadeSlideIn .15s ease;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
