/* ============================================
   CRGEN CRM - Complete Component System
   All Components - No Inline Styles Needed
   ============================================ */

/* ============================================
   Cards & Containers
   ============================================ */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-secondary);
}

.card-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-sidebar);
}

/* Warning Card */
.card-warning {
    border-left: 3px solid var(--warning);
}

.card-danger {
    border-left: 3px solid var(--danger);
}

.card-success {
    border-left: 3px solid var(--success);
}

.card-info {
    border-left: 3px solid var(--info);
}

/* ============================================
   Stat Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-600), var(--primary-400));
}

.stat-card.success::before {
    background: linear-gradient(90deg, var(--success), #34D399);
}

.stat-card.warning::before {
    background: linear-gradient(90deg, var(--warning), #FBBF24);
}

.stat-card.danger::before {
    background: linear-gradient(90deg, var(--danger), #F87171);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(91, 103, 245, 0.1);
    color: var(--primary-600);
}

.stat-card.success .stat-icon {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card.warning .stat-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-card.danger .stat-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-md);
    letter-spacing: -1px;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--danger);
}

.stat-trend-icon {
    font-size: 16px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-700);
    border-color: var(--primary-700);
    box-shadow: 0 0 0 3px rgba(91, 103, 245, 0.15);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--border-secondary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #DC2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #D97706;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group-inline {
    margin: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.form-label.required::after {
    content: '*';
    color: var(--danger);
    margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(91, 103, 245, 0.1);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239CA3AF' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 36px;
}

.form-help {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
    display: block;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: var(--space-xs);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
    box-shadow: 0 0 0 3px var(--danger-light);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.form-inline-grid {
    display: contents;
}

.form-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.form-container {
    background: var(--bg-primary);
    padding: var(--space-xl);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
}

.form-container h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.form-section {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
    margin-bottom: var(--space-xl);
}

.form-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

/* ============================================
   Tables
   ============================================ */
.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    margin-bottom: var(--space-xl);
}

.table-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg-sidebar);
}

.table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-primary);
}

.table th.th-checkbox {
    width: 40px;
}

.table th.th-actions {
    width: 100px;
}

.table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table a:not(.btn),
.data-table a:not(.btn) {
    color: var(--primary-600);
    text-decoration: none;
}

.table a:not(.btn):visited,
.data-table a:not(.btn):visited {
    color: var(--primary-600);
}

.table a:not(.btn):hover,
.data-table a:not(.btn):hover {
    color: var(--primary-700);
    text-decoration: underline;
}

.table-responsive {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-sidebar);
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-primary);
}

.data-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   Badges & Status
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1;
}

.badge-primary {
    background: rgba(91, 103, 245, 0.15);
    color: var(--primary-600);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-secondary {
    background: var(--slate-100);
    color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-new { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.status-first_contact { background: rgba(99, 102, 241, 0.15); color: #6366F1; }
.status-first_contact_pending { background: rgba(99, 102, 241, 0.15); color: #6366F1; }
.status-info_given { background: rgba(139, 92, 246, 0.15); color: #8B5CF6; }
.status-price_shared { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.status-interested { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.status-appointment_set { background: rgba(52, 211, 153, 0.15); color: #34D399; }
.status-arrived_clinic { background: rgba(20, 184, 166, 0.15); color: #14B8A6; }
.status-treatment_started { background: rgba(245, 158, 11, 0.15); color: #F59E0B; }
.status-treatment_ongoing { background: rgba(249, 115, 22, 0.15); color: #F97316; }
.status-treatment_completed { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.status-lost { background: rgba(239, 68, 68, 0.15); color: #EF4444; }
.status-unreachable { background: rgba(245, 158, 11, 0.15); color: #F59E0B; }
.status-called { background: rgba(139, 92, 246, 0.15); color: #8B5CF6; }
.status-callback_scheduled { background: rgba(251, 191, 36, 0.15); color: #FBBF24; }
.status-meeting_scheduled { background: rgba(52, 211, 153, 0.15); color: #34D399; }
.status-followup { background: rgba(251, 191, 36, 0.15); color: #FBBF24; }
.status-proposal_sent { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.status-negotiation { background: rgba(99, 102, 241, 0.15); color: #6366F1; }
.status-won { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.status-closed { background: rgba(107, 114, 128, 0.15); color: #6B7280; }
.status-archived { background: rgba(107, 114, 128, 0.15); color: #6B7280; }
.status-active { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.status-inactive { background: rgba(107, 114, 128, 0.15); color: #6B7280; }

/* Fallback for unknown statuses */
.status-badge:not([class*="status-"]),
.status-badge[class="status-badge"] {
    background: rgba(107, 114, 128, 0.15);
    color: #6B7280;
}

.status-completed {
    color: var(--success);
    font-weight: 500;
}

.status-completed::before {
    content: '✓ ';
}

/* ============================================
   Continue in next message...
   ============================================ */


/* ============================================
   Tags
   ============================================ */
.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    color: white;
    line-height: 1;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    color: white;
    line-height: 1;
}

.tag-item button,
.tag-item a {
    background: none;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    padding: 0;
    margin-left: var(--space-xs);
    font-size: 16px;
    line-height: 1;
    transition: opacity var(--transition-fast);
    text-decoration: none;
}

.tag-item button:hover,
.tag-item a:hover {
    opacity: 1;
}

.tag-list,
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.tag-badge {
    display: inline-block;
    padding: 5px 12px;
    background: rgba(91, 103, 245, 0.15);
    color: var(--primary-600);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

/* ============================================
   Timeline & Activity
   ============================================ */
.timeline {
    position: relative;
    padding-left: 40px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border-primary);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-md);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -40px;
    top: 4px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--primary-600);
    z-index: 1;
}

.timeline-marker.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.timeline-marker.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.timeline-marker.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.timeline-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.timeline-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-time {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.timeline-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: var(--space-xs);
}

.timeline-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-primary);
    font-size: 12px;
    color: var(--text-tertiary);
}

.activity-timeline {
    margin-top: var(--space-md);
}

.activity-item {
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-primary);
}

.activity-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    font-size: 13px;
}

.activity-type {
    font-weight: 600;
    color: var(--text-primary);
}

.activity-time {
    color: var(--text-tertiary);
    font-size: 12px;
}

.activity-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.activity-user {
    color: var(--primary-600);
    font-size: 13px;
    margin-top: var(--space-xs);
}

/* ============================================
   Notes & Reminders
   ============================================ */
.notes-list {
    margin-top: var(--space-md);
}

.note-item {
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-primary);
}

.note-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    font-size: 13px;
}

.note-date {
    color: var(--text-tertiary);
    font-size: 12px;
}

.note-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.reminder-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.reminder-card {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--warning);
}

.reminder-card.overdue {
    border-left-color: var(--danger);
    background: var(--danger-bg);
}

.reminder-card.completed {
    border-left-color: var(--success);
    opacity: 0.7;
}

.reminder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.reminder-priority {
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.reminder-priority.high {
    background: var(--danger-bg);
    color: var(--danger);
}

.reminder-priority.normal {
    background: var(--warning-bg);
    color: var(--warning);
}

.reminder-priority.low {
    background: var(--slate-100);
    color: var(--text-tertiary);
}

/* ============================================
   Status History
   ============================================ */
.status-history {
    margin-top: var(--space-md);
}

.status-history-item {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-primary);
}

.status-change {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.status-arrow {
    color: var(--text-tertiary);
    font-size: 16px;
}

.status-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.status-note {
    font-size: 13px;
    margin-top: var(--space-xs);
    color: var(--text-secondary);
}

/* ============================================
   Detail Grid & Sections
   ============================================ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.detail-section {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
}

.detail-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.detail-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.section {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    margin-bottom: var(--space-lg);
}

.section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.section-heading {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-heading-sm {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-tertiary);
}

.category-heading {
    margin-top: var(--space-lg);
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 600;
}

.info-row {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-primary);
    font-size: 14px;
    color: var(--text-secondary);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row strong {
    color: var(--text-primary);
    font-weight: 500;
    margin-right: var(--space-sm);
}

/* ============================================
   Filters
   ============================================ */

/* iOS Style Filters */
.ios-filters {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-primary);
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.ios-filters-header:hover {
    background: var(--bg-hover);
}

.ios-filters-header:active {
    background: var(--bg-tertiary);
}

.ios-filters-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.ios-filter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 8px;
    color: white;
}

.ios-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

.ios-filters-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-tertiary);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-filters:not(.open) .ios-filters-chevron {
    transform: rotate(-90deg);
}

.ios-filters-body {
    padding: 0 20px 20px;
    display: none;
    animation: iosSlideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-filters.open .ios-filters-body {
    display: block;
}

@keyframes iosSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* iOS Search */
.ios-filter-section {
    margin-bottom: 16px;
}

.ios-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.ios-search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.ios-search-input {
    width: 100%;
    height: 44px;
    padding: 0 44px 0 42px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.ios-search-input::placeholder {
    color: var(--text-tertiary);
}

.ios-search-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.ios-search-clear {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.ios-search-clear:hover {
    opacity: 1;
}

/* iOS Chips */
.ios-filter-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ios-chip {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 17px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ios-chip:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-secondary);
}

.ios-chip:active {
    transform: scale(0.96);
}

.ios-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* iOS Filter Groups */
.ios-filter-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.ios-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ios-filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 4px;
}

.ios-select-wrapper {
    position: relative;
}

.ios-select-wrapper::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-tertiary);
    pointer-events: none;
}

.ios-select {
    width: 100%;
    height: 44px;
    padding: 0 36px 0 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.2s ease;
}

.ios-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.ios-select:hover {
    border-color: var(--border-secondary);
}

.ios-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.ios-input::placeholder {
    color: var(--text-tertiary);
}

.ios-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* iOS Filter Row */
.ios-filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.ios-filter-half {
    flex: 1;
    min-width: 0;
}

/* iOS Date Inputs */
.ios-filter-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.ios-date-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ios-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ios-date-input-wrapper {
    position: relative;
    flex: 1;
}

.ios-date-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    font-size: 14px;
    color: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ios-date-input::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ios-date-placeholder {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-secondary);
    pointer-events: none;
}

.ios-date-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.ios-date-separator {
    color: var(--text-tertiary);
    font-size: 14px;
    flex-shrink: 0;
}

/* iOS Action Buttons */
.ios-filter-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary);
    margin-top: 8px;
}

.ios-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

.ios-btn:active {
    transform: scale(0.97);
}

.ios-btn-primary {
    flex: 2;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.ios-btn-primary:hover {
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.4);
    transform: translateY(-1px);
}

.ios-btn-secondary {
    flex: 1;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.ios-btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Legacy filters-panel support */
.filters-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    border-bottom: 1px solid transparent;
}

.filters-panel.open .filters-header {
    border-bottom-color: var(--border-primary);
}

.filters-header:hover {
    background: var(--bg-hover);
}

.filters-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.filters-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-100);
    border-radius: 8px;
    color: var(--primary-600);
}

.filters-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--primary-100);
    color: var(--primary-700);
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
}

.filters-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-tertiary);
    transition: transform 0.3s ease;
}

.filters-panel:not(.open) .filters-toggle {
    transform: rotate(-90deg);
}

.filters-body {
    padding: 20px;
    display: none;
}

.filters-panel.open .filters-body {
    display: block;
}

.filter-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    flex: 1;
    min-width: 0;
}

.filter-group-wide {
    flex: 2;
}

.filter-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.filter-actions {
    flex: none;
    width: auto;
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

@media (max-width: 992px) {
    .filter-row {
        flex-wrap: wrap;
    }
    
    .filter-group {
        flex: 1 1 calc(50% - 8px);
        min-width: calc(50% - 8px);
    }
    
    .filter-group-wide {
        flex: 1 1 100%;
    }
    
    .filter-actions {
        flex: 1 1 100%;
        width: 100%;
    }
    
    .filter-buttons {
        justify-content: flex-end;
    }
}

@media (max-width: 576px) {
    .filters-header {
        padding: 12px 16px;
    }
    
    .filters-body {
        padding: 16px;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .filter-group,
    .filter-group-wide {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    .filter-buttons {
        flex-direction: column;
    }
    
    .filter-buttons .btn {
        width: 100%;
    }
}

.filters {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
}

.filters form {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.filters input,
.filters select {
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.filters input[type="text"],
.filters input[type="number"],
.filters input[type="date"] {
    flex: 1;
    min-width: 150px;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(91, 103, 245, 0.1);
}

/* ============================================
   Bulk Operations
   ============================================ */
.bulk-bar {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    color: var(--text-primary);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    align-items: center;
    gap: var(--space-lg);
    z-index: var(--z-sticky);
    animation: slideUp 0.3s ease;
    min-width: 600px;
}

.bulk-bar.show {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.bulk-count {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
}

.bulk-actions .form-select {
    min-width: 150px;
}

/* ============================================
   Checkbox
   ============================================ */
.checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.checkbox input[type="checkbox"]:hover {
    border-color: var(--primary-600);
}

.checkbox input[type="checkbox"]:checked {
    background: var(--primary-600);
    border-color: var(--primary-600);
}

.checkbox input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.checkbox input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 103, 245, 0.1);
}

/* ============================================
   Quick Select
   ============================================ */
.quick-select {
    padding: 7px 12px;
    font-size: 13px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-select:hover {
    border-color: var(--border-focus);
    background: var(--bg-primary);
}

.quick-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(91, 103, 245, 0.1);
}

/* ============================================
   Messages & Alerts
   ============================================ */
.error-message,
.success-message,
.warning-message,
.info-message {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 14px;
}

.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    border-left: 3px solid var(--danger);
}

.success-message {
    background: var(--success-bg);
    color: var(--success);
    border-left: 3px solid var(--success);
}

.warning-message {
    background: var(--warning-bg);
    color: var(--warning);
    border-left: 3px solid var(--warning);
}

.info-message {
    background: var(--info-bg);
    color: var(--info);
    border-left: 3px solid var(--info);
}

.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-message {
    font-size: 14px;
}

.alert-success {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.alert-error {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-info {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--info);
}

/* ============================================
   Duplicate Warning
   ============================================ */
.duplicate-warning-heading {
    color: var(--warning);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.duplicate-warning-text {
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.duplicate-item,
.duplicate-item-box {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    border: 1px solid var(--border-primary);
}

.duplicate-item strong,
.duplicate-item-box strong {
    color: var(--text-primary);
}

.duplicate-item span,
.duplicate-item-box span {
    color: var(--text-secondary);
}

.duplicate-item a,
.duplicate-item-box a {
    margin-left: var(--space-sm);
}

/* ============================================
   Continue in next message...
   ============================================ */


/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

.empty-icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-icon-lg {
    font-size: 64px;
    opacity: 0.3;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.empty-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.no-data {
    text-align: center;
    color: var(--text-tertiary);
    padding: var(--space-xl);
    font-size: 14px;
}

/* ============================================
   Modal
   ============================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-modal-backdrop);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    pointer-events: none;
}

.modal-backdrop.show {
    display: flex;
    pointer-events: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border-secondary);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-sm);
    font-size: 24px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-modal-backdrop);
    pointer-events: none;
}

.modal-overlay.show {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.modal-dialog {
    position: relative;
    background: var(--bg-primary);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-secondary);
}

.modal-dialog h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-secondary);
    padding: var(--space-md);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.removing {
    animation: slideOutRight 0.2s ease forwards;
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.toast.success .toast-icon {
    background: var(--success-bg);
    color: var(--success);
}

.toast.error .toast-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.toast.warning .toast-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.toast.info .toast-icon {
    background: var(--info-bg);
    color: var(--info);
}

.toast-content {
    flex: 1;
}

.toast-message {
    font-size: 14px;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ============================================
   Audit Log
   ============================================ */
.audit-log-item {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    font-size: 13px;
    border: 1px solid var(--border-primary);
}

.audit-action {
    font-weight: 600;
    color: var(--text-primary);
}

.audit-user {
    color: var(--primary-600);
}

.audit-time {
    color: var(--text-tertiary);
    font-size: 12px;
}

.audit-changes {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Sidebar Overlay
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: calc(var(--z-fixed) - 1);
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    pointer-events: auto;
}

/* ============================================
   Divider
   ============================================ */
.divider {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: var(--space-xl) 0;
}

/* ============================================
   Helper Text
   ============================================ */
.helper-text {
    color: var(--text-tertiary);
    margin-bottom: var(--space-lg);
    font-size: 14px;
}

.text-muted {
    color: var(--text-tertiary);
}

.text-small {
    font-size: 12px;
}

/* ============================================
   Utility Classes
   ============================================ */

/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* Flex */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }
.align-center { align-items: center; }
.align-stretch { align-items: stretch; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Spacing */
.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.ml-0 { margin-left: 0 !important; }
.mr-0 { margin-right: 0 !important; }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.ml-xs { margin-left: var(--space-xs); }
.ml-sm { margin-left: var(--space-sm); }
.ml-md { margin-left: var(--space-md); }
.ml-lg { margin-left: var(--space-lg); }
.mr-xs { margin-right: var(--space-xs); }
.mr-sm { margin-right: var(--space-sm); }
.mr-md { margin-right: var(--space-md); }
.mr-lg { margin-right: var(--space-lg); }

.p-0 { padding: 0 !important; }
.pt-0 { padding-top: 0 !important; }
.pb-0 { padding-bottom: 0 !important; }
.pl-0 { padding-left: 0 !important; }
.pr-0 { padding-right: 0 !important; }

/* Width & Height */
.w-100 { width: 100%; }
.w-auto { width: auto; }
.h-100 { height: 100%; }
.h-auto { height: auto; }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Font Weight */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Text Size */
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }

/* Text Color */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }

/* Background Color */
.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-tertiary { background: var(--bg-tertiary); }

/* Border Radius */
.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded { border-radius: var(--radius); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow */
.shadow-none { box-shadow: none; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Position */
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }
.position-sticky { position: sticky; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* Transition */
.transition { transition: all var(--transition); }
.transition-fast { transition: all var(--transition-fast); }
.transition-slow { transition: all var(--transition-slow); }

/* Truncate */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Line Clamp */
.line-clamp-1 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
}

.line-clamp-2 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.line-clamp-3 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar-search {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .topbar {
        padding: 0 var(--space-md);
    }
    
    .topbar-search {
        display: none;
    }
    
    .page-content,
    .container {
        padding: var(--space-md);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .user-info {
        display: none;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .page-actions {
        width: 100%;
    }
    
    .filters form {
        flex-direction: column;
    }
    
    .filters input[type="text"],
    .filters input[type="number"],
    .filters input[type="date"],
    .filters select {
        width: 100%;
    }
    
    .filters-body {
        grid-template-columns: 1fr;
    }
    
    .table-wrapper {
        overflow-x: auto;
    }
    
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    .bulk-bar {
        left: var(--space-md);
        right: var(--space-md);
        transform: none;
        flex-direction: column;
        align-items: stretch;
        min-width: auto;
    }
    
    .bulk-actions {
        flex-direction: column;
    }
    
    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        max-width: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar,
    .topbar,
    .page-actions,
    .filters-panel,
    .bulk-bar,
    .toast-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .page-content,
    .container {
        padding: 0;
    }
    
    .card,
    .table-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}


/* ============================================
   Lead Detail Page Specific Styles
   ============================================ */

/* Tag Remove Button */
.tag-remove {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0 0 0 var(--space-xs);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.tag-remove:hover {
    opacity: 1;
}

/* Info Grid */
.info-grid {
    display: grid;
    gap: var(--space-sm);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-primary);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Reminder Priority Badges */
.reminder-priority {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: var(--space-sm);
}

.priority-high,
.reminder-priority.high {
    background: var(--danger-bg);
    color: var(--danger);
}

.priority-normal,
.reminder-priority.normal {
    background: var(--info-bg);
    color: var(--info);
}

.priority-low,
.reminder-priority.low {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

/* Reminder Note */
.reminder-note {
    margin-top: var(--space-sm);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* Activity User Icon */
.activity-user {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Notes List Spacing */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Reminder List Spacing */
.reminder-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Status History Spacing */
.status-history {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Activity Timeline Spacing */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Grid 2 Columns */
.grid-2-cols {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

@media (max-width: 768px) {
    .grid-2-cols {
        grid-template-columns: 1fr;
    }
}

/* Align Center */
.align-center {
    align-items: center;
}

/* Gap Utilities */
.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

/* Justify Between */
.justify-between {
    justify-content: space-between;
}

/* Text Primary 600 */
.text-primary-600 {
    color: var(--primary-600);
    text-decoration: none;
}

.text-primary-600:visited {
    color: var(--primary-600);
}

.text-primary-600:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Text Muted */
.text-muted {
    color: var(--text-tertiary);
}

/* Width 100% */
.w-100 {
    width: 100%;
}

/* Margin Bottom XL */
.mb-xl {
    margin-bottom: var(--space-xl);
}

/* Margin Top XL */
.mt-xl {
    margin-top: var(--space-xl);
}


/* ============================================
   Custom Dialog System (replaces prompt/confirm/alert)
   ============================================ */
.crm-dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.crm-dialog-overlay.active {
    display: flex;
    pointer-events: auto;
}

@keyframes crmDialogFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.crm-dialog {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 420px;
    padding: 24px;
    animation: crmDialogSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes crmDialogSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.crm-dialog-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.crm-dialog-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

.crm-dialog-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.crm-dialog-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.crm-dialog-input-wrap {
    margin-bottom: 16px;
}

.crm-dialog-input {
    width: 100%;
    font-size: 15px !important;
    padding: 12px !important;
}

.crm-dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.crm-dialog-actions .btn {
    min-width: 80px;
}

/* Mobile dialog adjustments */
@media (max-width: 768px) {
    .crm-dialog-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .crm-dialog {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0));
        animation: crmDialogSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes crmDialogSlideUp {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }

    .crm-dialog-actions {
        flex-direction: column-reverse;
    }

    .crm-dialog-actions .btn {
        width: 100%;
        padding: 14px;
        font-size: 15px;
    }
}


/* ============================================
   Audit Log - Overflow Fix
   ============================================ */
.audit-changes {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    word-break: break-word;
    font-size: 13px;
}

.audit-change-row {
    padding: 4px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
}

.audit-change-row strong {
    color: var(--text-primary);
    flex-shrink: 0;
}

.audit-summary {
    color: var(--text-secondary);
    word-break: break-all;
}

.audit-expand-btn {
    background: none;
    border: none;
    color: var(--primary-500);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
}

.audit-expand-btn:hover {
    text-decoration: underline;
}

.audit-detail-pre {
    margin-top: 6px;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
}


/* ============================================
   SAFETY: Ensure hidden overlays never block clicks
   ============================================ */
.sidebar-overlay:not(.active),
.modal-backdrop:not(.show),
.modal-overlay:not(.show),
.crm-dialog-overlay:not(.active) {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}


/* ============================================
   Dashboard Tabs & Widgets
   ============================================ */
.dash-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.dash-tabs::-webkit-scrollbar { display: none; }

.dash-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.dash-tab:hover { color: var(--text-primary); }
.dash-tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

.sales-widgets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.grid-2-cols {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.profile-icon-primary { background: rgba(99,102,241,0.1); color: #6366F1; }
.profile-icon-success { background: rgba(16,185,129,0.1); color: #10B981; }
.profile-icon-warning { background: rgba(245,158,11,0.1); color: #F59E0B; }
.profile-icon-purple { background: rgba(139,92,246,0.1); color: #8B5CF6; }

.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================
   Settings Page
   ============================================ */
.settings-layout {
    display: flex;
    gap: var(--space-lg);
    align-items: flex-start;
}

.settings-nav {
    min-width: 220px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    position: sticky;
    top: calc(var(--topbar-height) + var(--space-lg));
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.settings-nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.settings-nav-item.active {
    color: var(--primary-600);
    font-weight: 600;
    background: var(--bg-hover);
    border-left-color: var(--primary-600);
}

.settings-content { 
    flex: 1; 
    min-width: 0;
    min-height: 500px; /* Sabit minimum yukseklik - sayfa kaymasi onlenir */
}

.settings-field {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-primary);
}
.settings-field:last-of-type { border-bottom: none; }

.settings-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.settings-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-600);
    flex-shrink: 0;
}

.settings-field-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.settings-field-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    margin-bottom: 6px;
}

.settings-input { max-width: 320px; }
.settings-input-sm { max-width: 180px; }


/* ============================================
   PROFILE PAGE
   ============================================ */
.profile-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    max-width: 600px;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-600);
    color: white;
    font-size: 32px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.profile-role {
    font-size: 14px;
    color: var(--primary-500);
    font-weight: 500;
    margin: 0 0 4px 0;
}

.profile-email {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0;
}


/* ============================================
   Stats Bar
   ============================================ */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-primary);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.stats-bar .stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    text-align: center;
    flex-shrink: 0;
}

.stats-bar .stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stats-bar .stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .stats-bar {
        margin: 0 -16px 16px;
        padding: 12px 16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        gap: 10px;
    }
    
    .stats-bar .stat-box {
        min-width: 90px;
        padding: 12px 14px;
    }
    
    .stats-bar .stat-number {
        font-size: 22px;
    }
    
    .stats-bar .stat-label {
        font-size: 11px;
    }
}


/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 0;
    flex-wrap: wrap;
}

.pagination .page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination .page-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

.pagination .page-btn.active {
    background: var(--primary-600);
    border-color: var(--primary-600);
    color: #ffffff;
    font-weight: 600;
}

.pagination .page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination .page-dots {
    color: var(--text-tertiary);
    padding: 0 4px;
}

@media (max-width: 768px) {
    .pagination {
        padding: 16px 0;
    }
    
    .pagination .page-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
}


/* ============================================
   Lead Detail - Modern Right Panel
   ============================================ */
.lead-detail-right-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
}

/* Tab Navigation */
.lead-detail-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.lead-detail-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lead-detail-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.lead-detail-tab.active {
    background: var(--bg-primary);
    color: var(--primary-600);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lead-detail-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lead-detail-tab-icon svg {
    width: 16px;
    height: 16px;
}

.lead-detail-tab-text {
    display: none;
}

.lead-detail-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--bg-tertiary);
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
}

.lead-detail-tab.active .lead-detail-tab-count {
    background: rgba(91, 103, 245, 0.15);
    color: var(--primary-600);
}

.lead-detail-tab-count.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Tab Panels */
.lead-detail-panels {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.lead-detail-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.2s ease;
}

.lead-detail-panel.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* List Container */
.lead-detail-list {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    padding-right: 4px;
}

.lead-detail-list::-webkit-scrollbar {
    width: 6px;
}

.lead-detail-list::-webkit-scrollbar-track {
    background: transparent;
}

.lead-detail-list::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

.lead-detail-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Empty State */
.lead-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-tertiary);
}

.lead-detail-empty svg {
    margin-bottom: var(--space-md);
    opacity: 0.4;
}

.lead-detail-empty p {
    font-size: 14px;
    margin: 0;
}

/* Note Form */
.lead-detail-form {
    margin-bottom: var(--space-lg);
}

.lead-detail-form-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.lead-detail-textarea {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    resize: none;
    transition: all 0.2s ease;
}

.lead-detail-textarea:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(91, 103, 245, 0.1);
}

.lead-detail-textarea::placeholder {
    color: var(--text-tertiary);
}

.lead-detail-form-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-600);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.lead-detail-form-btn:hover {
    background: var(--primary-700);
    transform: scale(1.05);
}

.lead-detail-form-btn:active {
    transform: scale(0.95);
}

/* Note Cards */
.lead-detail-note-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    transition: all 0.2s ease;
}

.lead-detail-note-card:hover {
    border-color: var(--border-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.lead-detail-note-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.lead-detail-note-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.lead-detail-note-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.lead-detail-note-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.lead-detail-note-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

.lead-detail-note-content {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    word-break: break-word;
}

/* Reminder Form */
.lead-detail-reminder-form {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
}

.lead-detail-reminder-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.lead-detail-reminder-field {
    flex: 1;
    min-width: 140px;
}

.lead-detail-reminder-field-sm {
    flex: 0 0 100px;
    min-width: 100px;
}

.lead-detail-reminder-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.lead-detail-reminder-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--primary-600);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lead-detail-reminder-btn:hover {
    background: var(--primary-700);
}

/* Reminder Cards */
.lead-detail-reminder-card {
    display: flex;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    transition: all 0.2s ease;
}

.lead-detail-reminder-card:hover {
    border-color: var(--border-secondary);
}

.lead-detail-reminder-indicator {
    width: 4px;
    border-radius: 2px;
    background: var(--warning);
    flex-shrink: 0;
}

.lead-detail-reminder-card.priority-high .lead-detail-reminder-indicator {
    background: var(--danger);
}

.lead-detail-reminder-card.priority-low .lead-detail-reminder-indicator {
    background: var(--text-tertiary);
}

.lead-detail-reminder-card.overdue {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
}

.lead-detail-reminder-card.overdue .lead-detail-reminder-indicator {
    background: var(--danger);
}

.lead-detail-reminder-card.completed {
    opacity: 0.6;
}

.lead-detail-reminder-card.completed .lead-detail-reminder-indicator {
    background: var(--success);
}

.lead-detail-reminder-content {
    flex: 1;
    min-width: 0;
}

.lead-detail-reminder-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.lead-detail-reminder-datetime {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.lead-detail-reminder-datetime svg {
    color: var(--text-tertiary);
}

.lead-detail-reminder-priority-badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lead-detail-reminder-priority-badge.priority-high {
    background: var(--danger-bg);
    color: var(--danger);
}

.lead-detail-reminder-priority-badge.priority-normal {
    background: var(--warning-bg);
    color: var(--warning);
}

.lead-detail-reminder-priority-badge.priority-low {
    background: var(--slate-100);
    color: var(--text-tertiary);
}

.lead-detail-reminder-note {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.lead-detail-reminder-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-detail-reminder-complete-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--success);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lead-detail-reminder-complete-btn:hover {
    background: #059669;
}

.lead-detail-reminder-completed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--success);
}

/* Timeline (Activities) */
.lead-detail-timeline {
    position: relative;
    padding-left: 28px;
}

.lead-detail-timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-primary);
}

.lead-detail-timeline-item {
    position: relative;
    padding-bottom: var(--space-md);
}

.lead-detail-timeline-item:last-child {
    padding-bottom: 0;
}

.lead-detail-timeline-marker {
    position: absolute;
    left: -28px;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(91, 103, 245, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.lead-detail-timeline-marker svg {
    width: 12px;
    height: 12px;
    color: var(--primary-600);
}

.lead-detail-timeline-marker.primary {
    background: rgba(91, 103, 245, 0.1);
}

.lead-detail-timeline-marker.primary svg {
    color: var(--primary-600);
}

.lead-detail-timeline-marker.success {
    background: rgba(16, 185, 129, 0.1);
}

.lead-detail-timeline-marker.success svg {
    color: var(--success);
}

.lead-detail-timeline-marker.warning {
    background: rgba(245, 158, 11, 0.1);
}

.lead-detail-timeline-marker.warning svg {
    color: var(--warning);
}

.lead-detail-timeline-marker.info {
    background: rgba(59, 130, 246, 0.1);
}

.lead-detail-timeline-marker.info svg {
    color: var(--info);
}

.lead-detail-timeline-marker.purple {
    background: rgba(139, 92, 246, 0.1);
}

.lead-detail-timeline-marker.purple svg {
    color: #8B5CF6;
}

.lead-detail-timeline-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: all 0.2s ease;
}

.lead-detail-timeline-content:hover {
    border-color: var(--border-secondary);
}

.lead-detail-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.lead-detail-timeline-type {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.lead-detail-timeline-time {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.lead-detail-timeline-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 6px;
}

.lead-detail-timeline-user {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--primary-600);
}

.lead-detail-timeline-user svg {
    color: var(--text-tertiary);
}

/* History */
.lead-detail-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: all 0.2s ease;
}

.lead-detail-history-item:hover {
    border-color: var(--border-secondary);
}

.lead-detail-history-flow {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.lead-detail-history-arrow {
    display: flex;
    align-items: center;
    color: var(--text-tertiary);
}

.lead-detail-history-arrow svg {
    width: 18px;
    height: 18px;
}

.lead-detail-history-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* Responsive - Show tab text on larger screens */
@media (min-width: 600px) {
    .lead-detail-tab-text {
        display: inline;
    }
    
    .lead-detail-tab {
        padding: 10px 16px;
    }
}

@media (min-width: 900px) {
    .lead-detail-list {
        max-height: 500px;
    }
}


/* ============================================
   Lead Detail - Scroll Fade Effect
   ============================================ */
.lead-detail-list {
    position: relative;
}

.lead-detail-list-wrapper {
    position: relative;
}

/* Fade overlay at bottom of scrollable lists - only when has-fade class */
.lead-detail-list.has-fade::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, var(--bg-primary) 0%, var(--bg-primary) 20%, transparent 100%);
    pointer-events: none;
    display: block;
    margin-top: -60px;
    z-index: 2;
}

/* Timeline specific fade */
.lead-detail-timeline.has-fade::after {
    margin-left: -28px;
    padding-left: 28px;
}

/* ============================================
   Lead Detail - Health Tourism Section
   ============================================ */
.lead-detail-health-tourism {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-primary);
}

.lead-detail-health-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.lead-detail-health-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.lead-detail-health-header h4 svg {
    color: var(--primary-600);
}

.lead-detail-health-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lead-detail-health-edit-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

.lead-detail-health-body {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.lead-detail-health-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.lead-detail-health-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lead-detail-health-item-full {
    grid-column: 1 / -1;
}

.lead-detail-health-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lead-detail-health-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.lead-detail-health-value small {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Health Tourism Edit Mode */
.lead-detail-health-edit {
    margin-top: var(--space-md);
}

.lead-detail-health-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.lead-detail-health-edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lead-detail-health-edit-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lead-detail-health-edit-field .form-input,
.lead-detail-health-edit-field .form-select {
    padding: 8px 10px;
    font-size: 13px;
}

.lead-detail-health-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-primary);
}

.lead-detail-health-edit-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .lead-detail-health-grid,
    .lead-detail-health-edit-grid {
        grid-template-columns: 1fr;
    }
    
    .lead-detail-health-item-full {
        grid-column: 1;
    }
}


/* ============================================
   CRM Modal - Objection Tags
   ============================================ */
.crm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.crm-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.crm-modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.crm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.crm-modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.crm-modal-header h3 svg {
    color: var(--warning);
}

.crm-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.crm-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.crm-modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.crm-modal-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 var(--space-lg) 0;
}

.crm-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.crm-modal-footer .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Objection Modal Tags */
.objection-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.objection-modal-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.objection-modal-tag svg {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.objection-modal-tag:hover {
    border-color: var(--tag-color, var(--primary-500));
    background: var(--bg-tertiary);
}

.objection-modal-tag.selected {
    background: var(--tag-color, var(--primary-500));
    border-color: var(--tag-color, var(--primary-500));
    color: white;
}

.objection-modal-tag.selected svg {
    opacity: 1;
}

.objection-modal-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
}

.objection-modal-empty p {
    margin: 0 0 var(--space-md) 0;
}


/* Modal Section Styles */
.crm-modal-section {
    margin-bottom: var(--space-lg);
}

.crm-modal-section:last-child {
    margin-bottom: 0;
}

.crm-modal-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.crm-modal-label.required::after {
    content: ' *';
    color: var(--danger);
}

.crm-modal-label .text-tertiary {
    font-weight: 400;
}


/* ============================================
   Loss Modal (used in lead-detail.php)
   ============================================ */
.loss-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.loss-modal-overlay[style*="display: flex"],
.loss-modal-overlay[style*="display:flex"] {
    display: flex !important;
}

.loss-modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.loss-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-primary);
}

.loss-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.loss-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.loss-modal-close:hover {
    color: var(--text-primary);
}

.loss-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.loss-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}
