@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.2);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    --info: #06b6d4;
    --info-glow: rgba(6, 182, 212, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Light Mode Overrides for Default Theme */
body.mode-light {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --accent: #4f46e5;
    --accent-hover: #3b31c0;
    --accent-glow: rgba(79, 70, 229, 0.15);
}

/* PTI Theme - Dark Mode Overrides */
body.theme-pti {
    --bg-primary: #111625; /* Deep Charcoal */
    --bg-secondary: #12285A; /* Midnight Navy */
    --bg-card: rgba(18, 40, 90, 0.7);
    --border-color: rgba(74, 96, 122, 0.4); /* Slate Blue */
    --text-primary: #F9F8F3; /* Soft Alabaster */
    --text-secondary: #a0aab8;
    --text-muted: #6b7787;
    --accent: #F43604; /* Electric Scarlet */
    --accent-hover: #d32d03;
    --accent-glow: rgba(244, 54, 4, 0.25);
    --warning: #E5A93C; /* Warm Ochre */
    --warning-glow: rgba(229, 169, 60, 0.15);
}

/* PTI Theme - Light Mode Overrides */
body.theme-pti.mode-light {
    --bg-primary: #F9F8F3; /* Soft Alabaster */
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: #4A607A; /* Slate Blue */
    --text-primary: #111625; /* Deep Charcoal */
    --text-secondary: #4a5468;
    --text-muted: #7f8b9e;
    --accent: #F43604; /* Electric Scarlet */
    --accent-hover: #d32d03;
    --accent-glow: rgba(244, 54, 4, 0.15);
    --warning: #E5A93C; /* Warm Ochre */
    --warning-glow: rgba(229, 169, 60, 0.15);
}

/* Make sidebar dark Midnight Navy in PTI Light Mode to look premium and satisfy 30% structural block */
body.theme-pti.mode-light aside {
    background-color: #12285A;
    color: #F9F8F3;
    border-left: 1px solid rgba(74, 96, 122, 0.3);
}
body.theme-pti.mode-light aside a.nav-link {
    color: #a0aab8 !important;
}
body.theme-pti.mode-light aside a.nav-link:hover,
body.theme-pti.mode-light aside a.nav-link.active {
    color: #F9F8F3 !important;
    background-color: rgba(244, 54, 4, 0.15) !important;
    border-right: 4px solid #F43604 !important;
}
body.theme-pti.mode-light aside .brand-name {
    color: #F9F8F3 !important;
}
body.theme-pti.mode-light aside .brand-logo svg {
    fill: #F43604 !important;
}

/* Sidebar Real-Time Shamsi Clock & Calendar Widget */
.sidebar-clock-widget {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin: 10px 0 14px 0;
    text-align: center;
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05), 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
}

.sidebar-clock-widget:hover {
    border-color: var(--accent-glow, rgba(244, 54, 4, 0.3));
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.08), 0 6px 18px rgba(0, 0, 0, 0.25);
}

.clock-time-display {
    font-family: inherit;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #F9F8F3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.clock-date-display {
    font-size: 0.82rem;
    color: #a0aab8;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

body.theme-pti.mode-light aside .user-profile-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
body.theme-pti.mode-light aside .user-profile-panel .user-name {
    color: #F9F8F3 !important;
}
body.theme-pti.mode-light aside .user-profile-panel .user-role {
    color: #a0aab8 !important;
}
body.theme-pti.mode-light header {
    background-color: #ffffff;
    border-bottom: 1px solid #4A607A;
}
body.theme-pti.mode-light header h2 {
    color: #12285A !important;
}

/* ══ LOGIN SCREEN ══════════════════════════════════════ */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
                      radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 60%);
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.auth-logo {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--accent), var(--info));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 0 20px var(--accent-glow);
    overflow: hidden;
}

.auth-logo svg {
    width: 36px;
    height: 36px;
    fill: white;
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.auth-title {
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form .btn {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    padding: 14px;
    font-size: 1rem;
}

@media (max-width: 480px) {
    .auth-card {
        margin: 16px;
        padding: 28px 20px;
    }
    .auth-title {
        font-size: 1.1rem;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App container */
#app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar styling */
aside {
    width: 260px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    transition: var(--transition);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--info));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--accent-glow);
}

.brand-logo svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-profile-panel {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.9rem;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.switch-user-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-weight: 600;
}

.switch-user-btn:hover {
    background: var(--accent);
    color: white;
}

/* Sidebar navigation */
nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

.nav-link.active {
    background: linear-gradient(90deg, var(--accent-glow) 0%, transparent 100%);
    border-right: 3px solid var(--accent);
    color: var(--accent);
}

/* Main Content Area */
main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex children from stretching */
    background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.03) 0%, transparent 50%);
}

header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background-color: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(10px);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 800;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* View Containers */
.view-container {
    padding: 32px;
    flex-grow: 1;
    display: none;
    overflow-y: auto;
}

.view-container.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* User Selection Screen */
#user-selection-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.auth-card {
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: var(--radius-lg);
    width: 450px;
    max-width: 100%;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.auth-logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent), var(--info));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.auth-logo svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.user-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    max-height: 250px;
    overflow-y: auto;
    padding-left: 4px;
    margin-bottom: 24px;
}

.user-select-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.user-select-card:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
    transform: translateX(-4px);
}

/* Dashboard Styles */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

select, input[type="text"], input[type="number"], input[type="date"], textarea {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    outline: none;
    font-size: 0.85rem;
    transition: var(--transition);
    width: 100%;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}

.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }
.stat-card.info::after { background: var(--info); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
}

.stat-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.chart-body {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pipeline / Kanban Styles */
.pipeline-board {
    display: grid;
    grid-template-columns: repeat(7, 300px);
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 16px;
    align-items: start;
}

.pipeline-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    max-height: calc(100vh - 220px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.column-badge {
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 20px;
    font-weight: 700;
}

/* Col gradients */
.col-lead .column-badge { background: var(--info-glow); color: var(--info); }
.col-followup .column-badge { background: var(--warning-glow); color: var(--warning); }
.col-demo .column-badge { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.col-invoice .column-badge { background: var(--accent-glow); color: var(--accent); }
.col-won .column-badge { background: var(--success-glow); color: var(--success); }
.col-lost .column-badge { background: var(--danger-glow); color: var(--danger); }

.column-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 100px;
    padding: 2px;
}

.lead-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: grab;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lead-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.lead-card:active {
    cursor: grabbing;
}

.lead-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.patient-name {
    font-size: 0.9rem;
    font-weight: 700;
}

.physician-tag {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.lead-product {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    width: fit-content;
}

.lead-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lead-owner {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.lead-owner-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
}

/* Modals & Dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 15, 25, 0.7);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 600px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes modalSlide {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 800;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

/* Detail view tabs */
.tab-headers {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    gap: 16px;
}

.tab-header {
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab-header.active {
    color: var(--accent);
    border-color: var(--accent);
}

.tab-body {
    display: none;
}

.tab-body.active {
    display: block;
}

/* Checklist list */
.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
}

.checklist-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.checklist-item.checked span {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    padding-right: 16px;
}

.timeline::after {
    content: '';
    position: absolute;
    right: 4px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border-color);
}

.timeline-event {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-dot {
    position: absolute;
    right: -16px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid var(--bg-secondary);
    z-index: 2;
}

.timeline-event.active .timeline-dot {
    background: var(--accent);
}

.timeline-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.timeline-action {
    font-size: 0.8rem;
    font-weight: 700;
}

.timeline-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Product & Team grids */
.data-grid-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

th, td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

th {
    background-color: rgba(255,255,255,0.02);
    font-weight: 700;
    color: var(--text-secondary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: rgba(255,255,255,0.01);
}

.hamburger-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    align-items: center;
    justify-content: center;
}
.hamburger-menu-btn:hover {
    background: var(--border-color);
}

/* Responsive design */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
    }
    
    .hamburger-menu-btn {
        display: flex;
    }
    
    aside {
        width: 100%;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
        transition: max-height 0.3s ease;
    }
    
    .brand {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }
    
    /* Collapsed state by default on mobile */
    aside nav, aside .user-profile-panel {
        display: none !important;
    }
    
    /* Expanded state when aside has active class */
    aside.active nav {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px;
        margin-top: 16px;
        width: 100%;
    }
    
    aside.active .user-profile-panel {
        display: flex !important;
        margin-top: 16px;
        width: 100%;
    }
    
    aside nav a {
        width: 100%;
        margin-bottom: 0 !important;
        padding: 12px !important;
        font-size: 0.9rem;
    }
    
    header {
        height: auto;
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .view-container {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .pipeline-board {
        flex-direction: column;
        gap: 20px;
        overflow-x: visible;
        padding-bottom: 0;
    }
    
    .pipeline-column {
        width: 100%;
        min-width: 100%;
        max-height: 400px;
    }
    
    .data-grid-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-md);
        margin-top: 10px;
    }
    
    .data-grid-container table {
        min-width: 750px;
        width: 100%;
    }

    .data-grid-container th, 
    .data-grid-container td {
        padding: 8px 10px !important;
        font-size: 0.82rem !important;
    }

    .data-grid-container td .btn-sm {
        padding: 5px 8px !important;
        font-size: 0.78rem !important;
    }
    
    .modal-content {
        width: 95% !important;
        margin: 10px auto;
        padding: 16px;
    }
    
    .tab-headers {
        flex-wrap: wrap;
    }
    
    .tab-header {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Stack grid fields on small screens */
    form div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}


/* --- NEW STYLES: Timeline, Badges, and Autocomplete --- */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    margin-right: 8px;
}

/* Patient Log Timeline */
.timeline {
    position: relative;
    padding-right: 20px;
    border-right: 2px solid var(--border-color);
    margin-right: 10px;
    margin-top: 15px;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: 2px solid var(--bg-card);
    border-radius: 50%;
    right: -27px; /* Align with the border */
    top: 5px;
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 5px;
}

.timeline-content {
    background: var(--bg-body);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.timeline-content strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 4px;
}
.timeline-content p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* HTML5 Datalist tweak */
input[list] {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: left 10px top 50%;
    background-size: 10px auto;
}

/* ═══════════════════════════════════════════════════════════ */
/* v3: FILE UPLOAD CARDS                                       */
/* ═══════════════════════════════════════════════════════════ */
.file-upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 4px;
}

.file-upload-card {
    background: var(--bg-body, #111827);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md, 14px);
    padding: 16px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.file-upload-card:hover,
.file-upload-card.has-file {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.file-upload-card label {
    cursor: pointer;
    display: block;
    width: 100%;
}

.file-upload-icon {
    font-size: 2rem;
    margin-bottom: 6px;
    line-height: 1;
}

.file-upload-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.file-upload-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    word-break: break-all;
}

.file-upload-preview {
    width: 100%;
    max-height: 80px;
    object-fit: cover;
    border-radius: 6px;
    margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════ */
/* v3: TRANSFERS TABS                                          */
/* ═══════════════════════════════════════════════════════════ */
.tabs-header {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tabs-header .tab-header {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    margin-bottom: -2px;
}

.tabs-header .tab-header:hover { color: var(--text-primary); background: var(--border-color); }
.tabs-header .tab-header.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }

.transfers-tab { animation: fadeIn 0.2s ease; }

/* ═══════════════════════════════════════════════════════════ */
/* v3: STATUS BADGES in tables                                 */
/* ═══════════════════════════════════════════════════════════ */
.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}
.status-pill.accepted { background: var(--success-glow); color: var(--success); }
.status-pill.pending  { background: var(--warning-glow); color: var(--warning); }
.status-pill.rejected { background: rgba(244, 54, 4, 0.15); color: #F43604; }

/* ═══════════════════════════════════════════════════════════ */
/* v3: IRC input highlight                                     */
/* ═══════════════════════════════════════════════════════════ */
input:invalid:not(:placeholder-shown) {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px var(--danger-glow);
}

/* ═══════════════════════════════════════════════════════════ */
/* v3: Patient log table action link                           */
/* ═══════════════════════════════════════════════════════════ */
.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}
.btn-link:hover { color: var(--accent-hover); }

/* Performance: will-change on animated elements */
.nav-link, .btn, .modal-overlay { will-change: transform, opacity; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.lead-card.awaiting-approval {
    background: rgba(229, 169, 60, 0.12) !important;
    border: 2px solid var(--secondary-accent) !important;
    box-shadow: 0 0 10px rgba(229, 169, 60, 0.2) !important;
}

/* ═══════════════════════════════════════════════════════════ */
/* v6.0.0: Physicians & Meeting Star Rating Styles             */
/* ═══════════════════════════════════════════════════════════ */
.star-rating-select {
    display: flex;
    gap: 8px;
    direction: ltr;
    font-size: 1.7rem;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}
.star-rating-select span {
    color: var(--text-muted);
    transition: transform 0.15s, color 0.15s;
}
.star-rating-select span.active {
    color: #f59e0b;
}
.star-rating-display {
    color: #f59e0b;
    font-weight: bold;
    letter-spacing: 2px;
}
.status-pill.missed {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-pill.completed {
    background: rgba(16, 185, 129, 0.18);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-pill.scheduled {
    background: rgba(59, 130, 246, 0.18);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Modal Z-Index Overlay Hierarchy */
#modal-physician-history { z-index: 1000 !important; }
#modal-physician-visit { z-index: 1080 !important; }
#modal-physician { z-index: 1080 !important; }
