/* START OF FILE: style.css */

:root {
    /* Theme Variables */
    --primary: #2563eb;       
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-dim: #dbeafe;
    
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-col: #f1f5f9;
    
    --text-main: #0f172a;
    --text-sec: #64748b;
    --border: #e2e8f0;
    
    /* Status Colors */
    --st-new: #3b82f6;        
    --st-short: #8b5cf6;      
    --st-pend: #f59e0b;       
    --st-conf: #10b981;       
    --st-run: #06b6d4;        
    --st-lost: #64748b;       
    
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;

    /* Dimensions */
    --header-height: 60px;
    --nav-height: 70px; /* Fixed height for nav */
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom);
    
    /* Z-Index Hierarchy (Bulletproof Layering) */
    --z-content: 1;
    --z-header: 100;
    --z-nav: 500;      /* High priority for Bottom Bar */
    --z-fab: 600;      /* Above Nav */
    --z-sidebar: 800;  
    --z-overlay: 799;
    --z-details: 900;  /* Full screen details */
    --z-modal: 1000;   /* Top most */
    --z-loader: 9999;
}

/* Dark Theme Variables */
body.dark-mode {
    --primary: #3b82f6;
    --primary-light: #1e293b;
    --primary-dim: #334155;
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-col: #334155;
    --text-main: #f8fafc;
    --text-sec: #94a3b8;
    --border: #334155;
    --danger-bg: #450a0a;
    --danger-border: #7f1d1d;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent; outline: none; }

/* BODY SETUP - NATIVE APP FEEL */
body { 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    /* 100dvh handles mobile browser address bars dynamically */
    height: 100dvh; 
    width: 100vw;
    overflow: hidden; /* Prevent body scroll, only views scroll */
    overscroll-behavior-y: none; /* No bounce effect */
    position: fixed; /* Locks the body in place */
    left: 0; top: 0; right: 0; bottom: 0;
}

/* --- MAIN APP WRAPPER --- */
#crm-app {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* --- 1. LOADER & LOGIN SCREEN --- */
#app-loader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body); z-index: var(--z-loader);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.loader-spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border); border-top: 4px solid var(--primary);
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#login-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body); z-index: 5000;
    display: flex; justify-content: center; align-items: center;
    padding: 20px;
}
.login-card {
    background: var(--bg-card); padding: 40px 30px; border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1); text-align: center;
    width: 100%; max-width: 400px; border: 1px solid var(--border);
}
.login-logo { font-size: 3rem; color: var(--primary); margin-bottom: 10px; }
.login-title { font-size: 1.5rem; font-weight: 800; color: var(--text-main); margin-bottom: 5px; }
.login-desc { color: var(--text-sec); margin-bottom: 30px; font-size: 0.95rem; }

.google-btn {
    background-color: var(--bg-card); color: var(--text-main);
    border: 1px solid var(--border); padding: 12px 20px;
    border-radius: 30px; cursor: pointer; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    transition: 0.2s; width: 100%; font-size: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.google-btn:hover { background-color: var(--bg-col); }

/* --- 2. HEADER --- */
.app-header {
    background: var(--bg-card); height: var(--header-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem; border-bottom: 1px solid var(--border); 
    position: relative; z-index: var(--z-header);
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.menu-btn { background: none; border: none; font-size: 1.2rem; color: var(--text-main); cursor: pointer; padding: 5px; }
.logo { font-weight: 800; font-size: 1.2rem; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.header-actions { display: flex; gap: 15px; align-items: center; }
.header-pending-block { text-align: right; padding-left: 12px; border-left: 1px solid var(--border); }
.header-pending-block .label { font-size: 0.7rem; color: var(--text-sec); }
.header-pending-val { font-weight: 700; font-size: 0.9rem; color: var(--st-pend); transition: color 0.2s; }
.header-pending-block.warning .header-pending-val { color: #d97706; }
.header-pending-block.danger .header-pending-val { color: var(--danger); }
.theme-toggle { background: none; border: none; font-size: 1.2rem; color: var(--text-sec); cursor: pointer; }
.header-bell-wrap { position: relative; }
.header-bell-wrap .theme-toggle { position: relative; }
.header-bell-badge {
    position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px;
    font-size: 0.6rem; font-weight: 700; background: var(--danger); color: white;
    border-radius: 8px; display: none; align-items: center; justify-content: center;
    box-sizing: border-box; line-height: 1;
}
.btn-reassign {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
    background: var(--bg-card); color: var(--primary); border: 1px solid var(--primary);
    font-size: 0.85rem; font-weight: 600; cursor: pointer; margin-left: 8px;
}
.btn-reassign:active { opacity: 0.9; }
.assign-request-item { flex-direction: column; align-items: stretch; }

/* Install app button (header, show on mobile) */
.install-app-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.install-app-btn:active { opacity: 0.9; }
@media (max-width: 640px) {
    .install-app-btn { display: inline-flex; }
}
@media (min-width: 641px) {
    .install-app-btn.force-show { display: inline-flex; }
}
.install-app-btn.hidden { display: none !important; }
.install-app-text { white-space: nowrap; }

/* --- 3. SIDEBAR --- */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: var(--z-overlay); 
    display: none; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

.sidebar {
    position: fixed; top: 0; left: -280px; width: 280px; height: 100%;
    background: var(--bg-card); z-index: var(--z-sidebar); 
    transition: left 0.3s ease;
    display: flex; flex-direction: column; border-right: 1px solid var(--border);
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}
.sidebar.active { left: 0; }

.sidebar-header {
    height: var(--header-height); display: flex; align-items: center; justify-content: flex-end;
    padding: 0 1.2rem;
}
.close-sidebar { background: none; border: none; font-size: 1.2rem; color: var(--text-sec); cursor: pointer; }

/* User Profile */
.user-profile-header {
    padding: 0 15px 15px 15px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border); margin-bottom: 5px;
}
.user-avatar-small {
    width: 45px; height: 45px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--primary); padding: 2px;
}
.user-details { display: flex; flex-direction: column; overflow: hidden; justify-content: center; }
.user-name-text { font-weight: 700; font-size: 0.95rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { font-size: 0.75rem; color: var(--st-conf); display: flex; align-items: center; gap: 4px; font-weight: 500; }

.sidebar-content { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 5px; }
.sb-group-title { font-size: 0.75rem; color: var(--text-sec); font-weight: 700; text-transform: uppercase; margin: 15px 0 5px 10px; }
.sb-item {
    padding: 12px 15px; border-radius: 8px; color: var(--text-main); font-weight: 500; font-size: 0.95rem;
    display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background 0.2s; text-decoration: none;
}
.sb-item:active { background: var(--bg-col); }
.sb-item i { width: 20px; color: var(--text-sec); text-align: center; }

/* --- 4. VIEW CONTAINER --- */
.view-container { 
    flex: 1; 
    position: relative; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column;
}

/* General View Style */
.view { 
    width: 100%; 
    height: 100%; 
    display: none; 
    flex-direction: column; 
    overflow-y: auto; 
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; 
    
    /* CRITICAL: Padding bottom to prevent content hiding behind fixed nav */
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
}
.view.active { display: flex; }

/* DETAILS VIEW (Full Screen) */
#view-details {
    z-index: var(--z-details); 
    background: var(--bg-body);
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    /* Extra padding for details view specifically */
    padding-bottom: 0; 
}
#view-details .scroll-area { 
    /* The footer in details view is also fixed, so we need padding there */
    padding-bottom: 150px !important; 
}

/* --- 5. DASHBOARD & LISTS --- */
.search-area { padding: 10px 1rem; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-input { width: 100%; padding: 10px 15px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-body); color: var(--text-main); font-size: 0.9rem; }

.filter-chips-container::-webkit-scrollbar { display: none; }
.chip {
    padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text-sec); font-size: 0.8rem; font-weight: 600;
    white-space: nowrap; cursor: pointer; transition: all 0.2s;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.dash-header { padding: 1.5rem 1rem 1rem 1rem; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dash-greeting { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 5px; }
.dash-date { font-size: 0.9rem; color: var(--text-sec); }

.dash-stats-row { display: flex; gap: 10px; padding: 1rem; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.dash-today-perf { padding-top: 0.25rem; padding-bottom: 0.5rem; }
.d-stat {
    flex: 1; min-width: 100px; padding: 15px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.d-stat-val { font-size: 1.4rem; font-weight: 800; color: var(--text-main); }
.d-stat-lbl { font-size: 0.75rem; color: var(--text-sec); margin-top: 4px; text-transform: uppercase; }

.dash-section-title { padding: 1rem 1rem 0.5rem 1rem; font-weight: 700; color: var(--text-sec); font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; }
.dash-task-list { padding: 0 1rem; display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem; }

/* Dashboard Tasks */
.dash-task {
    background: var(--bg-card); padding: 12px; border-radius: 10px; border: 1px solid var(--border);
    display: flex; gap: 12px; align-items: center; position: relative; overflow: hidden;
}
.dash-task:active { transform: scale(0.98); }
.dash-task.overdue { border-left: 4px solid var(--danger); }
.dash-task.today { border-left: 4px solid var(--st-conf); }
.dt-icon {
    width: 36px; height: 36px; background: var(--bg-col); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 0.9rem;
}
.dash-task.overdue .dt-icon { color: var(--danger); background: #fef2f2; }
.dt-content { flex: 1; }
.dt-title { font-weight: 600; font-size: 0.95rem; color: var(--text-main); margin-bottom: 2px; }
.dt-sub { font-size: 0.8rem; color: var(--text-sec); display: flex; align-items: center; gap: 6px; }
.empty-state { text-align: center; padding: 2rem; color: var(--text-sec); font-size: 0.9rem; }

/* Important Leads – 2 rows × 5 columns, icons only (left to right) */
.dash-important-leads-section { padding: 0 1rem 1rem; margin-bottom: 0.5rem; }
.dash-important-leads-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 0.5rem 0;
}
.dash-important-lead-icon {
    aspect-ratio: 1;
    max-width: 56px;
    width: 100%;
    margin: 0 auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}
.dash-important-lead-icon:active { transform: scale(0.92); }
.dash-important-lead-icon:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

/* Team Ranking */
.dash-ranking-section { padding: 0 1rem 1rem; margin-bottom: 0.5rem; }
.ranking-table { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ranking-header, .ranking-row {
    display: grid;
    grid-template-columns: 32px 1fr 44px 44px 44px 70px;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    font-size: 0.8rem;
}
.ranking-header { background: var(--bg-col); color: var(--text-sec); font-weight: 700; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.ranking-row { border-bottom: 1px solid var(--border); color: var(--text-main); }
.ranking-row:last-child { border-bottom: none; }
.ranking-row-me { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.rank-num { font-weight: 700; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-won { color: var(--st-conf); font-weight: 600; text-align: center; }
.rank-lost { color: var(--danger); text-align: center; }
.rank-active { color: var(--st-pend); text-align: center; }
.rank-value { color: var(--text-sec); font-size: 0.75rem; text-align: right; }

/* Lead List Item */
.lead-list-item {
    background: var(--bg-card); padding: 12px; border-radius: 10px; border: 1px solid var(--border);
    display: flex; gap: 12px; align-items: center; cursor: pointer; transition: background 0.2s;
}
.lead-list-item:active { background: var(--bg-col); transform: scale(0.99); }
.ll-avatar {
    width: 42px; height: 42px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0; border: 1px solid var(--primary-dim);
}
.ll-info { flex: 1; overflow: hidden; }
.ll-name { font-weight: 700; font-size: 0.95rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ll-sub { font-size: 0.8rem; color: var(--text-sec); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.ll-status { font-size: 0.65rem; padding: 3px 8px; border-radius: 12px; font-weight: 700; white-space: nowrap; background: var(--bg-col); color: var(--text-sec); border: 1px solid var(--border); }

/* --- 6. BOARD VIEW --- */
.board-wrapper {
    display: flex; overflow-x: auto; 
    height: 100%; padding: 1rem 0.5rem; gap: 1rem; scroll-snap-type: x mandatory;
    /* Extra padding for bottom nav */
    padding-bottom: 120px;
}
.board-col {
    min-width: 85vw; scroll-snap-align: center;
    background: var(--bg-col); border-radius: var(--radius);
    display: flex; flex-direction: column; border: 1px solid var(--border);
    height: 100%;
}
.col-header {
    padding: 1rem; font-weight: 700; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border); background: var(--bg-card); color: var(--text-main);
    border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 0; z-index: 5;
    flex-shrink: 0;
}
.col-body { flex: 1; overflow-y: auto; padding: 0.8rem; display: flex; flex-direction: column; gap: 0.8rem; }

.card {
    background: var(--bg-card); border-radius: var(--radius); padding: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); position: relative; border: 1px solid var(--border);
}
.card:active { transform: scale(0.98); }
.card.rotting { border: 1px solid var(--danger); background: var(--danger-bg); }
.decay-badge {
    position: absolute; top: -8px; right: 10px;
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 700;
    display: flex; align-items: center; gap: 3px; z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.decay-badge.red { background: var(--danger); color: #fff; }
.hot-badge {
    position: absolute; top: -8px; left: 10px;
    background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3;
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 700;
    display: flex; align-items: center; gap: 3px; z-index: 2;
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.card-name { font-weight: 700; font-size: 1rem; color: var(--text-main); }
.card-company { font-size: 0.8rem; color: var(--text-sec); font-weight: 500; display: flex; align-items: center; gap: 5px; margin-bottom: 8px;}
.card-price { font-weight: 700; color: var(--st-conf); font-size: 0.85rem; background: rgba(16, 185, 129, 0.1); padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.project-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.75rem; color: var(--primary); background: var(--primary-light);
    padding: 2px 8px; border-radius: 4px; font-weight: 600; margin-bottom: 8px;
    border: 1px solid var(--primary-dim);
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: var(--bg-col); color: var(--text-sec); font-weight: 500; border: 1px solid var(--border); }
.card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 0.75rem; color: var(--text-sec); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.task-badge { font-size: 0.75rem; color: var(--st-pend); display: flex; align-items: center; gap: 4px; font-weight: 600; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-mini { 
    flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; 
    background: var(--bg-card); font-size: 0.85rem; font-weight: 600; color: var(--text-sec);
    display: flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer;
}
.btn-mini.primary { background: var(--primary); color: white; border: none; }

.assign-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-sec); padding: 4px 10px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border); }
.assign-badge.mine { color: var(--st-conf); border-color: var(--st-conf); background: rgba(34, 197, 94, 0.1); }
.btn-assign-me { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; background: var(--primary); color: white; border: none; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.btn-assign-me:active { opacity: 0.9; }

/* --- 7. STATS VIEW --- */
.scroll-area { 
    flex: 1; overflow-y: auto; padding: 1rem; scrollbar-width: none;
    /* IMPORTANT: Ensure bottom padding for stats view as well */
    padding-bottom: 150px; 
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.stat-box { background: var(--bg-card); padding: 1.2rem; border-radius: var(--radius); text-align: center; border: 1px solid var(--border); }
.stat-box.full { grid-column: span 2; }
.stat-num { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin: 5px 0; }
.stat-lbl { font-size: 0.8rem; color: var(--text-sec); }
.forecast-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--primary-light) 100%);
    border: 1px solid var(--primary-dim); padding: 1.5rem; border-radius: var(--radius);
    margin-bottom: 1rem; text-align: center; position: relative; overflow: hidden;
}
.forecast-val { font-size: 2rem; font-weight: 800; color: var(--primary); margin: 5px 0; }
.forecast-sub { font-size: 0.9rem; color: var(--text-sec); display: flex; justify-content: space-between; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px;}
.progress-bar { height: 6px; width: 100%; background: var(--border); border-radius: 3px; margin-top: 10px; overflow: hidden; display: flex;}
.prog-fill { height: 100%; }

/* --- 8. BOTTOM NAV (FIXED) --- */
.bottom-nav {
    position: fixed; /* FIXED POSITION to solve the issue */
    bottom: 0; 
    left: 0;
    width: 100%;
    /* Ensure it handles the safe area (home bar) */
    height: calc(var(--nav-height) + var(--safe-bottom)); 
    background: rgba(255, 255, 255, 0.96); /* Glass effect */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: flex-start;
    padding-top: 12px;
    padding-bottom: var(--safe-bottom); 
    z-index: var(--z-nav); /* High priority */
    box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
}
body.dark-mode .bottom-nav { background: rgba(30, 41, 59, 0.96); }

.nav-link { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-sec); font-size: 0.75rem; text-decoration: none; min-width: 52px; flex: 1; max-width: 72px; }
.nav-link i { font-size: 1.3rem; }
.nav-link.active { color: var(--primary); font-weight: 600; }
.nav-link-with-badge .nav-icon-wrap { position: relative; display: inline-flex; }
.nav-badge {
    position: absolute; top: -6px; right: -8px; min-width: 16px; height: 16px; padding: 0 4px;
    font-size: 0.6rem; font-weight: 700; background: var(--primary); color: white;
    border-radius: 8px; display: none; align-items: center; justify-content: center;
    box-sizing: border-box; line-height: 1;
}
.nav-count-badge { font-size: 0.8rem; background: var(--bg-col); padding: 2px 8px; border-radius: 10px; color: var(--text-main); font-weight: 600; }

/* --- 9. FAB (FIXED) + menu --- */
.fab-wrap {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
    right: 20px;
    z-index: var(--z-fab);
}
.fab-main {
    width: 56px; height: 56px; background: var(--primary); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); border: none;
    cursor: pointer; transition: transform 0.2s;
}
.fab-main:active { transform: scale(0.9); }
.fab-menu {
    position: absolute;
    bottom: 64px;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}
.fab-menu.open { display: flex; }
.fab-menu-item {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.detail-ops-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 10px 1rem;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-main);
    align-items: center;
}
body.dark-mode .detail-ops-strip {
    background: var(--primary-dim);
}
.ops-strip-item { white-space: nowrap; }

.po-summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 12px;
    background: var(--bg-col);
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
}

.ledger-container, .milestone-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}
.ledger-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    background: var(--bg-col);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.ledger-row .li-note, .ledger-row .lo-note { grid-column: 1 / -1; }
.ledger-row .ledger-row-del {
    grid-column: 1 / -1;
    justify-self: end;
    width: auto;
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: var(--text-sec);
    cursor: pointer;
}

.milestone-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-col);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.milestone-row .ms-title { flex: 1 1 140px; min-width: 100px; }
.milestone-row .ms-owner { flex: 1 1 100px; min-width: 80px; }
.milestone-row .ms-due { width: auto; min-width: 130px; }
.milestone-row .ledger-row-del { margin-left: auto; }

.dash-project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    gap: 12px;
}
.dash-project-row:active { background: var(--bg-col); }
.dash-project-row-warn { border-left: 3px solid var(--danger); }
.dpr-main { flex: 1; min-width: 0; }
.dpr-main strong { display: block; font-size: 0.9rem; }
.dpr-meta { font-size: 0.75rem; color: var(--text-sec); margin-top: 4px; }

.dash-task-assignee-filter {
    font-size: 0.72rem;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
}
.dash-task-assignee-filter.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* --- 10. MODALS --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: var(--z-modal); 
    display: none; backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; align-items: flex-end; }

.bottom-sheet {
    background: var(--bg-card); width: 100%; border-radius: 20px 20px 0 0;
    padding: 0; max-height: 95vh; height: 95vh; color: var(--text-main);
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.modal-overlay.open .bottom-sheet { transform: translateY(0); }

/* --- 11. FORM STYLES --- */
.stage-bar {
    display: flex; gap: 0; background: var(--bg-card);
    overflow-x: auto; scrollbar-width: none;
    width: 100%; padding: 10px 5px; flex-shrink: 0;
}
.stage-step {
    flex: 0 0 auto; min-width: 90px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-col); color: var(--text-sec);
    font-size: 0.75rem; font-weight: 600; cursor: pointer;
    position: relative; margin-right: 4px; padding: 0 20px 0 25px;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
}
.stage-step:first-child { 
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); 
    padding-left: 15px; border-radius: 4px 0 0 4px; 
}
.stage-step:last-child { 
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); 
    border-radius: 0 4px 4px 0; margin-right: 0;
}
.stage-step.active { background: var(--primary); color: white; z-index: 2; }
.stage-step.completed { background: var(--primary-dim); color: var(--primary-dark); }
.stage-step.lost-state { background: var(--danger); color: white; clip-path: none; border-radius: 4px; width: 100%; text-align: center; padding: 0;}

.modal-tabs {
    display: flex; border-bottom: 1px solid var(--border);
    background: var(--bg-card); flex-shrink: 0;
    overflow-x: auto; white-space: nowrap; 
}
.modal-tab {
    flex: 1; text-align: center; padding: 15px 10px;
    font-weight: 600; color: var(--text-sec); cursor: pointer;
    border-bottom: 2px solid transparent; font-size: 0.95rem; min-width: auto;
}
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 20px; }
.tab-content.active { display: block; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; }
.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-size: 0.85rem; color: var(--text-sec); margin-bottom: 8px; font-weight: 500;}
.form-input, .form-textarea, .form-select {
    width: 100%; padding: 12px 15px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 1rem; background: var(--bg-body); color: var(--text-main); transition: border 0.2s;
}
.form-input:focus { border-color: var(--primary); background: var(--bg-card); }
.form-section-title {
    font-size: 0.8rem; font-weight: 700; color: var(--primary);
    text-transform: uppercase; margin: 25px 0 10px 0;
    border-bottom: 1px dashed var(--border); padding-bottom: 5px;
}
.password-wrapper { position: relative; width: 100%; }
.toggle-pass {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    cursor: pointer; color: var(--text-sec); font-size: 0.9rem; padding: 5px;
}
.img-preview-box { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }
.preview-thumb {
    width: 60px; height: 60px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-col);
    cursor: pointer; transition: transform 0.2s;
}
.upload-status { font-size: 0.75rem; color: var(--st-pend); margin-left: 8px; font-weight: 600; display: none; }

.prio-group { display: flex; gap: 10px; width: 100%; }
.prio-btn { 
    flex: 1; text-align: center; padding: 12px; 
    border: 1px solid var(--border); border-radius: 8px; 
    cursor: pointer; font-size: 0.9rem; color: var(--text-main); 
    background: var(--bg-card); transition: all 0.2s; font-weight: 500;
}
.prio-btn:has(input:checked) { 
    border-color: var(--primary); background: var(--primary-light); 
    color: var(--primary); font-weight: 700; box-shadow: inset 0 0 0 1px var(--primary);
}

/* Form Footer */
#form-footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: var(--bg-card);
    background-color: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px);
    padding: 15px 20px calc(15px + var(--safe-bottom)) 20px;
    border-top: 1px solid var(--border); 
    z-index: 60; 
    display: flex; flex-direction: column; gap: 12px;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.08);
}
body.dark-mode #form-footer { background-color: rgba(30, 41, 59, 0.9); }
.btn-save { 
    width: 100%; padding: 15px; border-radius: 10px; border: none;
    background: var(--primary); color: white; font-weight: 600; font-size: 1rem; cursor: pointer;
}
.btn-delete { 
    width: 100%; padding: 14px; border-radius: 10px; font-weight: 600; font-size: 1rem; cursor: pointer;
    background: var(--bg-card); color: var(--danger); border: 1px solid var(--danger-border); 
}

/* Activity & Timeline */
.follow-up-count-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 16px; margin-bottom: 16px; background: var(--primary-light);
    border: 1px solid var(--primary-dim); border-radius: var(--radius);
}
.follow-up-label { font-weight: 700; color: var(--text-main); font-size: 0.9rem; }
.follow-up-value { font-weight: 800; font-size: 1.1rem; }
.follow-up-hint { display: block; width: 100%; margin-top: 4px; font-size: 0.75rem; color: var(--text-sec); }

.act-toggle-row { 
    display: flex; background: var(--bg-body); padding: 4px; 
    border-radius: 10px; border: 1px solid var(--border); margin-bottom: 20px;
}
.act-toggle { 
    flex: 1; text-align: center; padding: 10px; font-size: 0.9rem; font-weight: 600; 
    cursor: pointer; border-radius: 7px; color: var(--text-sec); border: none; transition: all 0.2s;
}
.act-toggle.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.activity-input-box {
    background: var(--bg-col); padding: 15px; border-radius: 12px; 
    border: 1px solid var(--border); margin-bottom: 20px;
}
.input-group-joined { display: flex; align-items: stretch; width: 100%; gap: 10px; margin-bottom: 10px; }
.form-select-icon {
    width: 50px; padding: 0; text-align: center; border: 1px solid var(--border);
    border-radius: 8px; background: var(--bg-card); font-size: 1.2rem;
    appearance: none; -webkit-appearance: none; display: flex; align-items: center; justify-content: center;
}
.form-input-joined {
    flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 1rem; background: var(--bg-card); color: var(--text-main);
}
.task-item { 
    display: flex; align-items: center; gap: 12px; padding: 14px; 
    border: 1px solid var(--border); background: var(--bg-card); border-radius: 10px; margin-bottom: 12px;
    position: relative; overflow: hidden;
}
.task-item.overdue { border-left: 5px solid var(--danger); background: #fff1f2; border-color: #fecaca;}
.task-chk { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; border-radius: 4px;}
.task-meta { flex: 1; }
.tm-text { font-weight: 600; font-size: 1rem; color: var(--text-main); display: block; margin-bottom: 4px; }
.tm-date { font-size: 0.8rem; color: var(--text-sec); display: flex; align-items: center; gap: 5px; }
.timeline { 
    border-left: 2px solid var(--border); margin-left: 10px; padding-left: 25px; 
    padding-bottom: 20px; position: relative;
}
.t-item { position: relative; margin-bottom: 25px; }
.t-item::before {
    content: ''; position: absolute; left: -32px; top: 0; width: 12px; height: 12px;
    background: var(--bg-card); border: 2px solid var(--primary); border-radius: 50%; z-index: 2;
}
.t-date { font-size: 0.75rem; color: var(--text-sec); margin-bottom: 8px; display: block; font-weight: 500;}
.t-content { 
    font-size: 0.95rem; color: var(--text-main); background: var(--bg-card); 
    padding: 15px; border-radius: 8px; border: 1px solid var(--border); 
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.outcome-badge {
    display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 2px 8px;
    border-radius: 4px; margin-bottom: 6px; border: 1px solid var(--border);
}

/* Utils */
.tag-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.tag-chk { display: none; }
.tag-lbl { 
    padding: 8px 16px; background: var(--bg-body); border-radius: 20px; 
    font-size: 0.9rem; cursor: pointer; border: 1px solid var(--border); color: var(--text-main);
}
.tag-chk:checked + .tag-lbl { background: var(--primary-light); color: var(--primary); border-color: var(--primary); font-weight: 600; }

.action-list { margin-top: 10px; }
.action-item {
    padding: 15px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    font-size: 1rem; color: var(--text-main); cursor: pointer;
}
.action-item:active { background: var(--bg-col); }
.editor-list { margin-top: 15px; max-height: 300px; overflow-y: auto; }
.editor-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-bottom: 1px solid var(--border); font-size: 0.95rem;
}
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feat-chk { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-body); cursor: pointer;}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .feature-grid { grid-template-columns: 1fr; }
    .stage-step { min-width: 80px; font-size: 0.7rem; }
}