/* =========================================================
   Nova CRM — modern brand theme
   Brand colors taken from the logo: vibrant orange + slate.
   ========================================================= */

:root {
    --brand-orange: #F97316;
    --brand-orange-600: #EA580C;
    --brand-orange-700: #C2410C;
    --brand-orange-50: #FFF7ED;
    --brand-orange-100: #FFEDD5;
    --brand-orange-200: #FED7AA;

    --brand-dark: #0F172A;
    --brand-slate-900: #0F172A;
    --brand-slate-800: #1E293B;
    --brand-slate-700: #334155;
    --brand-slate-500: #64748B;
    --brand-slate-400: #94A3B8;
    --brand-slate-300: #CBD5E1;
    --brand-slate-200: #E2E8F0;
    --brand-slate-100: #F1F5F9;
    --brand-slate-50:  #F8FAFC;

    --status-new:        #94A3B8;
    --status-contacted:  #3B82F6;
    --status-qualified:  #10B981;
    --status-demo:       #8B5CF6;
    --status-won:        #16A34A;
    --status-lost:       #EF4444;
    --status-unqual:     #F59E0B;
    --status-unreach:    #94A3B8;

    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow:    0 1px 3px 0 rgba(15, 23, 42, 0.1), 0 1px 2px -1px rgba(15, 23, 42, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.1);

    --sidebar-width: 260px;
    --topbar-height: 64px;
}

html, body {
    font-family: 'Tajawal', 'Segoe UI', 'Cairo', Tahoma, Arial, sans-serif;
    background: var(--brand-slate-50);
    color: var(--brand-slate-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
}

a { color: var(--brand-orange-600); text-decoration: none; }
a:hover { color: var(--brand-orange-700); }

::selection {
    background: var(--brand-orange-200);
    color: var(--brand-orange-700);
}

/* ----- App shell ----- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.app-sidebar {
    background: var(--brand-slate-900);
    color: white;
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    z-index: 50;
}

.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1rem;
}

.app-sidebar .brand img {
    height: 38px;
    filter: brightness(0) invert(1);
}

.app-sidebar .brand-title {
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.app-sidebar .brand-title span {
    color: var(--brand-orange);
}

.app-sidebar .brand-subtitle {
    color: var(--brand-slate-400);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.app-sidebar .nav-section-title {
    color: var(--brand-slate-400);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 1rem 1.5rem 0.5rem;
    font-weight: 600;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: var(--brand-slate-300);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.15s;
    position: relative;
    border-radius: 0;
}

.app-sidebar .nav-link:hover {
    background: rgba(249, 115, 22, 0.08);
    color: white;
}

.app-sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.15) 0%, transparent 100%);
    color: var(--brand-orange);
}

[dir="rtl"] .app-sidebar .nav-link.active {
    background: linear-gradient(270deg, rgba(249, 115, 22, 0.15) 0%, transparent 100%);
}

.app-sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    inset-inline-end: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--brand-orange);
}

.app-sidebar .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.app-sidebar .nav-link.active .nav-icon {
    opacity: 1;
}

.app-sidebar .nav-badge {
    margin-inline-start: auto;
    background: var(--brand-orange);
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.app-sidebar .nav-badge.warn {
    background: #FBBF24;
    color: var(--brand-slate-900);
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--brand-slate-200);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

.app-topbar .page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-slate-900);
    margin: 0;
}

.app-topbar .user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.9rem;
    background: var(--brand-slate-50);
    border-radius: 999px;
    color: var(--brand-slate-800);
    font-weight: 500;
}

.app-topbar .user-chip .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-orange) 0%, var(--brand-orange-600) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.app-content {
    flex: 1;
    padding: 1.75rem 2rem;
    overflow-x: hidden;
}

/* Mobile burger toggle */
.sidebar-toggle {
    display: none;
    background: transparent;
    border: 0;
    color: var(--brand-slate-700);
    font-size: 1.4rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

@media (max-width: 991px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar {
        position: fixed;
        inset-inline-start: 0;
        top: 0;
        height: 100vh;
        width: var(--sidebar-width);
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }
    [dir="ltr"] .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); }
    .sidebar-toggle { display: inline-block; }
    .app-content { padding: 1.25rem 1rem; }
    .app-topbar { padding: 0 1rem; }
}

/* Mobile backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 45;
}
.sidebar-backdrop.show { display: block; }

/* ----- Cards ----- */
.card {
    border: 1px solid var(--brand-slate-200);
    border-radius: 14px;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s, transform 0.15s;
}

.card.shadow-sm { box-shadow: var(--shadow-sm); }
.card:hover { box-shadow: var(--shadow); }

.card-header {
    background: white;
    border-bottom: 1px solid var(--brand-slate-200);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--brand-slate-900);
    border-radius: 14px 14px 0 0 !important;
}

.card-body { padding: 1.25rem; }

/* Stat cards */
.stat-card {
    background: white;
    border: 1px solid var(--brand-slate-200);
    border-radius: 14px;
    padding: 1.25rem;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-orange-200);
}

.stat-card .stat-label {
    color: var(--brand-slate-500);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--brand-slate-900);
    line-height: 1;
    letter-spacing: -1px;
}

.stat-card .stat-icon {
    position: absolute;
    inset-inline-end: 1rem;
    top: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-orange-50);
    color: var(--brand-orange-600);
    font-size: 1.1rem;
}

.stat-card.stat-success .stat-icon { background: #DCFCE7; color: #16A34A; }
.stat-card.stat-danger  .stat-icon { background: #FEE2E2; color: #DC2626; }
.stat-card.stat-warning .stat-icon { background: #FEF3C7; color: #D97706; }
.stat-card.stat-info    .stat-icon { background: #DBEAFE; color: #2563EB; }

/* ----- Buttons ----- */
.btn {
    border-radius: 10px;
    font-weight: 600;
    padding: 0.5rem 1.1rem;
    transition: all 0.15s;
    border-width: 1px;
}

.btn-sm { border-radius: 8px; padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.btn-lg { border-radius: 12px; padding: 0.75rem 1.5rem; }

.btn-primary {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--brand-orange-600);
    border-color: var(--brand-orange-600);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
}

.btn-success {
    background: #16A34A;
    border-color: #16A34A;
}
.btn-success:hover { background: #15803D; border-color: #15803D; transform: translateY(-1px); }

.btn-warning {
    background: #F59E0B;
    border-color: #F59E0B;
    color: white;
}
.btn-warning:hover { color: white; background: #D97706; border-color: #D97706; }

.btn-danger { background: #EF4444; border-color: #EF4444; }
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }

.btn-outline-secondary {
    color: var(--brand-slate-700);
    border-color: var(--brand-slate-300);
    background: white;
}
.btn-outline-secondary:hover {
    background: var(--brand-slate-50);
    color: var(--brand-slate-900);
    border-color: var(--brand-slate-400);
}

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

/* ----- Tables ----- */
.table {
    margin-bottom: 0;
    color: var(--brand-slate-800);
}

.table thead {
    background: var(--brand-slate-50);
}

.table thead th {
    background: var(--brand-slate-50) !important;
    color: var(--brand-slate-700);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--brand-slate-200);
    padding: 0.85rem 1rem;
}

.table tbody td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--brand-slate-100);
    vertical-align: middle;
}

.table-dark thead th {
    background: var(--brand-slate-900) !important;
    color: white;
    border-color: var(--brand-slate-800);
}

.table-hover tbody tr {
    transition: background 0.1s;
}
.table-hover tbody tr:hover {
    background: var(--brand-orange-50);
}

.table-striped tbody tr:nth-of-type(odd) {
    background: var(--brand-slate-50);
}

/* ----- Forms ----- */
.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid var(--brand-slate-300);
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.form-control-sm, .form-select-sm {
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
}

.form-label {
    font-weight: 600;
    color: var(--brand-slate-700);
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

/* ----- Badges ----- */
.badge {
    font-weight: 600;
    padding: 0.35em 0.75em;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.2px;
}

.badge-status-New          { background: var(--status-new); color: white; }
.badge-status-Contacted    { background: var(--status-contacted); color: white; }
.badge-status-Qualified    { background: var(--status-qualified); color: white; }
.badge-status-Discovery    { background: #0EA5E9; color: white; }       /* sky blue */
.badge-status-DemoBooked   { background: var(--status-demo); color: white; }
.badge-status-DemoCompleted{ background: #7C3AED; color: white; }       /* indigo */
.badge-status-ProposalSent { background: #2563EB; color: white; }       /* royal blue */
.badge-status-Negotiation  { background: #F97316; color: white; }       /* brand orange */
.badge-status-Won          { background: var(--status-won); color: white; }
.badge-status-Lost         { background: var(--status-lost); color: white; }
.badge-status-Unqualified  { background: var(--status-unqual); color: white; }
.badge-status-Unreachable  { background: var(--status-unreach); color: white; }
.badge-status-Recall       { background: #FBBF24; color: #92400E; }       /* amber — call back later */
.badge-status-Hold         { background: #6B7280; color: white; }         /* slate gray — paused */

.badge-source-Meta            { background: #1877F2; }
.badge-source-Google          { background: #EA4335; }
.badge-source-LinkedIn        { background: #0A66C2; }
.badge-source-Referral        { background: #6366F1; }
.badge-source-WalkIn          { background: #06B6D4; }
.badge-source-ErpDynamicSite  { background: #F37021; }  /* ERP Dynamic brand orange */
.badge-source-NovaHrsSite     { background: #0EA5E9; }  /* Nova HR brand cyan */
.badge-source-Unknown         { background: var(--brand-slate-400); }
.badge-source-Other           { background: var(--brand-slate-600, #475569); }

/* ----- Alerts ----- */
.alert {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 0.85rem 1.1rem;
}

.alert-success {
    background: #DCFCE7;
    color: #166534;
    border-color: #BBF7D0;
}

.alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border-color: #FECACA;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border-color: #FDE68A;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border-color: #BFDBFE;
}

/* ----- Page header ----- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h2,
.page-header h1 {
    margin: 0;
    color: var(--brand-slate-900);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-header .lead-count {
    color: var(--brand-slate-500);
    font-size: 0.9rem;
}

/* ----- Timeline (Detail page activity) ----- */
.timeline-item {
    border-inline-start: 3px solid var(--brand-slate-200);
    padding: 0.65rem 1rem;
    margin-bottom: 0.85rem;
    background: var(--brand-slate-50);
    border-radius: 0 10px 10px 0;
    transition: all 0.15s;
}
[dir="rtl"] .timeline-item {
    border-radius: 10px 0 0 10px;
}

.timeline-item:hover { background: white; box-shadow: var(--shadow-sm); }
.timeline-item.created      { border-color: #16A34A; }
.timeline-item.statuschange { border-color: var(--brand-orange); }
.timeline-item.assignment   { border-color: #8B5CF6; }
.timeline-item.note         { border-color: var(--brand-slate-400); }
.timeline-item.lostrequested{ border-color: #F59E0B; background: #FEF3C7; }
.timeline-item.lostapproved { border-color: #EF4444; background: #FEE2E2; }
.timeline-item.lostrejected { border-color: var(--brand-slate-400); }

/* ----- Pagination ----- */
.page-link {
    color: var(--brand-orange-600);
    border-color: var(--brand-slate-200);
    border-radius: 8px;
    margin: 0 2px;
}
.page-link:hover { background: var(--brand-orange-50); color: var(--brand-orange-700); border-color: var(--brand-orange-200); }
.page-item.active .page-link {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
    color: white;
}

/* ----- Login page ----- */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--brand-slate-50);
}

.login-hero {
    background: linear-gradient(135deg, var(--brand-slate-900) 0%, var(--brand-slate-800) 60%, var(--brand-orange-700) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 4rem;
    position: relative;
    overflow: hidden;
}

.login-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(249, 115, 22, 0.2) 0, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(249, 115, 22, 0.15) 0, transparent 40%);
}

.login-hero > * { position: relative; }

/* Bigger + centered so the brand mark anchors the hero pane. A subtle
   soft shadow defines the icon's rounded square against the dark
   gradient (otherwise the dark-blue logo background fades into the
   dark slate hero and only the inner text is visible). */
.login-hero img {
    height: 160px;
    width: auto;             /* preserve aspect ratio — no stretch */
    object-fit: contain;
    align-self: center;
    margin: 0 auto 2rem;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(255, 255, 255, 0.08);
}

.login-hero h1 {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
    margin-bottom: 1rem;
}

.login-hero h1 span { color: var(--brand-orange); }

.login-hero p {
    color: var(--brand-slate-300);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 480px;
}

.login-hero .features {
    margin-top: 2.5rem;
    display: grid;
    gap: 0.85rem;
    max-width: 480px;
}

.login-hero .features li {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--brand-slate-200);
}

.login-hero .features li::before {
    content: '✓';
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}

.login-form-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: 18px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--brand-slate-200);
}

.login-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--brand-slate-900);
    margin-bottom: 0.4rem;
}

.login-card .subtitle {
    color: var(--brand-slate-500);
    margin-bottom: 1.75rem;
}

.login-card-mobile-logo {
    display: none;
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-card-mobile-logo img { height: 56px; width: auto; object-fit: contain; }

@media (max-width: 991px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .login-card-mobile-logo { display: block; }
}

/* ----- Misc utilities ----- */
.muted { color: var(--brand-slate-500); }
.divider { height: 1px; background: var(--brand-slate-200); margin: 1.5rem 0; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--brand-slate-500);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: var(--brand-orange-50);
    color: var(--brand-orange-600);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* ----- Animations ----- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.app-content > * {
    animation: fadeUp 0.25s ease-out;
}

/* Print: hide chrome */
@media print {
    .app-sidebar, .app-rail, .app-panel, .app-topbar, .sidebar-backdrop { display: none !important; }
    .app-shell { grid-template-columns: 1fr; display: block; }
    .app-content { padding: 0; }
}

/* ============================================================
   Phase 17 — Icon Rail + Section Panel sidebar
   Replaces the legacy .app-sidebar flat list. The rail is a
   narrow always-visible column of section icons; clicking an
   icon opens a wider panel containing that section's links.
   Clicking the same icon (or a link, via navigation) closes it.
   ============================================================ */

/* Switch shell to flex so we can have rail + (optional) panel + main */
.app-shell {
    display: flex !important;
    grid-template-columns: unset !important;
    min-height: 100vh;
}

/* The main column must fill all remaining horizontal space — otherwise the
   rail (68px) + panel (240px when open) sit on one side and the content
   shrinks to its intrinsic width, leaving a huge empty gap. */
.app-shell > .app-main {
    flex: 1 1 auto;
    min-width: 0;
}

/* ─── Rail (always visible on desktop, icon + label column) ─── */
.app-rail {
    width: 96px;
    flex-shrink: 0;
    background: var(--brand-slate-900);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 6px;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow-md);
}
.app-rail::-webkit-scrollbar { width: 0; }

.rail-brand {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    text-decoration: none;
    transition: background 0.15s;
}
.rail-brand:hover { background: rgba(255, 255, 255, 0.08); }
/* Logo: keep the asset's native aspect ratio (no stretch) by using
   object-fit: contain inside a max-width/max-height box. The previous
   whitewash filter was dropped now that the Nova CRM icon brings its
   own brand colors. */
.rail-brand img {
    max-width: 44px;
    max-height: 44px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.rail-btn {
    width: 84px;
    min-height: 66px;
    border: 0;
    background: transparent;
    color: var(--brand-slate-300);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    transition: background 0.15s, color 0.15s;
    position: relative;
    text-decoration: none;
    font-family: inherit;
}
.rail-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}
.rail-btn.active {
    background: rgba(249, 115, 22, 0.18);
    color: var(--brand-orange);
}
.rail-btn.current::before {
    content: '';
    position: absolute;
    inset-inline-end: -6px;
    top: 12px;
    bottom: 12px;
    width: 3px;
    background: var(--brand-orange);
    border-radius: 2px;
}
.rail-btn svg {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}
.rail-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.1px;
}
.rail-btn .rail-dot {
    position: absolute;
    top: 8px;
    inset-inline-end: 12px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #DC2626;
    border: 2px solid var(--brand-slate-900);
}
.rail-cta {
    margin-top: auto;
    background: var(--brand-orange);
    color: white;
}
.rail-cta:hover {
    background: var(--brand-orange-600, #DD5C0E);
    color: white;
}
.rail-cta.rail-btn { color: white; }

/* ─── Panel (hidden until a section is opened) ─── */
.app-panel {
    width: 0;
    flex-shrink: 0;
    background: white;
    border-inline-end: 1px solid var(--brand-slate-200);
    overflow: hidden;
    transition: width 0.18s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 49;
}
.app-shell[data-section-open] .app-panel {
    width: 240px;
    overflow-y: auto;
}
.panel-section {
    display: none;
    padding: 18px 10px;
}
.app-shell[data-section-open="sdr"]         .panel-section[data-section="sdr"],
.app-shell[data-section-open="sales"]       .panel-section[data-section="sales"],
.app-shell[data-section-open="analysis"]    .panel-section[data-section="analysis"],
.app-shell[data-section-open="marketing"]   .panel-section[data-section="marketing"],
.app-shell[data-section-open="commissions"] .panel-section[data-section="commissions"],
.app-shell[data-section-open="docs"]        .panel-section[data-section="docs"],
.app-shell[data-section-open="admin"]       .panel-section[data-section="admin"] {
    display: block;
}
.panel-title {
    padding: 4px 12px 12px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--brand-slate-500, #64748B);
    font-weight: 700;
}
.panel-section .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.9rem;
    color: var(--brand-slate-800, #1F2937);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.panel-section .nav-link:hover {
    background: var(--brand-slate-100, #F1F5F9);
    color: var(--brand-slate-900, #0F172A);
}
.panel-section .nav-link.active {
    background: rgba(249, 115, 22, 0.12);
    color: var(--brand-orange);
}
.panel-section .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}
.panel-section .nav-link.active .nav-icon { opacity: 1; }
.panel-section .nav-badge {
    margin-inline-start: auto;
    background: var(--brand-orange);
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}
.panel-section .nav-badge.warn {
    background: #FBBF24;
    color: var(--brand-slate-900);
}

/* ─── Notifications bell + dropdown in topbar ─── */
.notif-wrap { position: relative; }
.notif-btn {
    width: 40px;
    height: 40px;
    border: 0;
    background: var(--brand-slate-50, #F8FAFC);
    color: var(--brand-slate-700, #334155);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.15s, color 0.15s;
}
.notif-btn:hover {
    background: var(--brand-slate-100, #F1F5F9);
    color: var(--brand-slate-900, #0F172A);
}
.notif-count {
    position: absolute;
    top: -2px;
    inset-inline-end: -2px;
    background: #DC2626;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.2;
    border: 2px solid white;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    width: 360px;
    max-height: 480px;
    background: white;
    border: 1px solid var(--brand-slate-200, #E2E8F0);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
    overflow: hidden;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.notif-dropdown[hidden] { display: none; }
.notif-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--brand-slate-100, #F1F5F9);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-list { overflow-y: auto; max-height: 360px; }
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--brand-slate-50, #F8FAFC);
    color: var(--brand-slate-800, #1F2937);
    text-decoration: none;
    transition: background 0.12s;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--brand-slate-50, #F8FAFC); color: var(--brand-slate-900, #0F172A); }
.notif-item.unread { background: rgba(249, 115, 22, 0.04); }
.notif-item.unread .notif-msg { font-weight: 600; }
.notif-icon { font-size: 1.2rem; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-msg { font-size: 0.9rem; line-height: 1.4; }
.notif-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--brand-slate-100, #F1F5F9);
    text-align: center;
}
.notif-footer a {
    color: var(--brand-orange, #F37021);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
}
.notif-footer a:hover { text-decoration: underline; }

/* ─── Topbar search trigger (Ctrl+K) ─── */
.topbar-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--brand-slate-50, #F8FAFC);
    border: 1px solid var(--brand-slate-200, #E2E8F0);
    border-radius: 8px;
    padding: 6px 12px;
    color: var(--brand-slate-500, #64748B);
    cursor: pointer;
    font-size: 0.85rem;
    min-width: 240px;
    transition: border-color 0.15s, background 0.15s;
}
.topbar-search-trigger:hover {
    background: white;
    border-color: var(--brand-slate-300, #CBD5E1);
    color: var(--brand-slate-700, #334155);
}
.topbar-search-trigger kbd {
    margin-inline-start: auto;
    background: white;
    border: 1px solid var(--brand-slate-200, #E2E8F0);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--brand-slate-600, #475569);
    font-family: inherit;
}
@media (max-width: 991px) { .topbar-search-trigger { display: none; } }

/* ─── Global-search modal ─── */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}
.search-modal[hidden] { display: none; }
.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
}
.search-modal-box {
    position: relative;
    width: 90%;
    max-width: 640px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}
.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--brand-slate-100, #F1F5F9);
}
.search-input-wrap svg { color: var(--brand-slate-500, #64748B); flex-shrink: 0; }
.search-input-wrap input {
    flex: 1;
    border: 0;
    outline: 0;
    font-size: 1rem;
    background: transparent;
    font-family: inherit;
}
.search-input-wrap kbd {
    background: var(--brand-slate-100, #F1F5F9);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    color: var(--brand-slate-600, #475569);
    font-family: inherit;
}
.search-results {
    overflow-y: auto;
    max-height: calc(70vh - 60px);
}
.search-hint {
    padding: 30px;
    text-align: center;
    color: var(--brand-slate-500, #64748B);
    font-size: 0.9rem;
}
.search-section-title {
    padding: 10px 18px 6px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--brand-slate-500, #64748B);
    font-weight: 700;
    background: var(--brand-slate-50, #F8FAFC);
}
.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    text-decoration: none;
    color: var(--brand-slate-800, #1F2937);
    border-bottom: 1px solid var(--brand-slate-50, #F8FAFC);
}
.search-item:hover { background: rgba(249, 115, 22, 0.06); color: var(--brand-slate-900, #0F172A); }
.search-item-main { flex: 1; min-width: 0; }
.search-item small { display: block; }
.search-status {
    background: var(--brand-slate-100, #F1F5F9);
    color: var(--brand-slate-700, #334155);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

/* ─── Kanban board ─── */
.kanban-board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 12px;
    align-items: flex-start;
}
.kanban-col {
    flex: 0 0 280px;
    background: var(--brand-slate-50, #F8FAFC);
    border: 1px solid var(--brand-slate-200, #E2E8F0);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 240px);
}
.kanban-col-header {
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-bottom: 1px solid var(--brand-slate-200, #E2E8F0);
}
.kanban-count {
    background: var(--brand-slate-200, #E2E8F0);
    color: var(--brand-slate-700, #334155);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.kanban-col-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kanban-col-body.drop-target {
    background: rgba(249, 115, 22, 0.06);
    box-shadow: inset 0 0 0 2px var(--brand-orange, #F37021);
}
.kanban-card {
    background: white;
    border: 1px solid var(--brand-slate-200, #E2E8F0);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: grab;
    user-select: none;
    transition: box-shadow 0.15s, transform 0.05s;
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; transform: scale(0.98); }
.kanban-card-title {
    font-weight: 600;
    color: var(--brand-slate-900, #0F172A);
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
}
.kanban-card-title:hover { color: var(--brand-orange, #F37021); }
.kanban-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    gap: 6px;
    flex-wrap: wrap;
}
.kanban-deal {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--brand-slate-700, #334155);
}
.kanban-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 6px;
}
.kanban-tags .badge { font-size: 9px; }
.kanban-empty {
    text-align: center;
    color: var(--brand-slate-400, #94A3B8);
    padding: 20px 0;
    font-size: 0.85rem;
    font-style: italic;
}

/* ─── Bulk-actions toolbar on /Leads/Index ─── */
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--brand-slate-200, #E2E8F0);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
}
.bulk-toolbar[hidden] { display: none; }
.bulk-toolbar .bulk-count {
    background: var(--brand-orange, #F37021);
    color: white;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ─── Mobile: rail + panel slide in together via hamburger ─── */
@media (max-width: 991px) {
    .app-rail {
        position: fixed;
        inset-inline-start: 0;
        top: 0;
        height: 100vh;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }
    [dir="ltr"] .app-rail { transform: translateX(-100%); }
    .app-rail.show { transform: translateX(0); }

    .app-panel {
        position: fixed;
        inset-inline-start: 96px;
        top: 0;
        height: 100vh;
        z-index: 48;
    }
    .app-rail.show ~ .sidebar-backdrop { /* handled by JS .show toggle */ }
}


/* Phone numbers: force LTR display so the leading "+" stays on the left even
   inside RTL containers. Applies automatically to anything wrapped in
   <bdi class="phone"> or .phone, plus every tel: anchor. */
.phone, a[href^="tel:"], bdi.phone {
    direction: ltr;
    unicode-bidi: bidi-override;
    display: inline-block;
}

/* ───── Phase 12c — quick-edit pencil on /Leads/Index ───── */
.quick-cell {
    position: relative;
    white-space: nowrap;
}
.quick-edit-btn {
    background: transparent;
    border: 1px solid var(--brand-slate-200);
    color: var(--brand-slate-600);
    border-radius: 6px;
    width: 24px;
    height: 24px;
    line-height: 1;
    font-size: 13px;
    padding: 0;
    margin-inline-start: 4px;
    opacity: 0.4;
    transition: all 0.15s;
}
.quick-cell:hover .quick-edit-btn { opacity: 1; }
.quick-edit-btn:hover {
    background: var(--brand-orange);
    color: white;
    border-color: var(--brand-orange);
}

/* ───── Phase 12c — Timeline UI revamp ───── */
.timeline-item {
    position: relative;
    padding-inline-start: 2.4rem;
}
.timeline-item::before {
    content: "";
    position: absolute;
    inset-inline-start: 0.6rem;
    top: 0.85rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand-slate-200);
    box-shadow: 0 0 0 3px white;
}
.timeline-item.created::before      { background: #16A34A; }
.timeline-item.statuschange::before { background: var(--brand-orange); }
.timeline-item.assignment::before   { background: #8B5CF6; }
.timeline-item.note::before         { background: var(--brand-slate-500); }
.timeline-item.call::before         { background: #2563EB; }
.timeline-item.whatsapp::before     { background: #25D366; }
.timeline-item.email::before        { background: #DC2626; }
.timeline-item.saleshandoff::before { background: #DB2777; }
.timeline-item.lostrequested::before{ background: #F59E0B; }
.timeline-item.lostapproved::before { background: #EF4444; }
.timeline-item.lostrejected::before { background: var(--brand-slate-500); }
.timeline-item.wonrequested::before { background: #84CC16; }
.timeline-item.wonapproved::before  { background: #16A34A; }
.timeline-item.wonrejected::before  { background: var(--brand-slate-500); }

/* ───── Phase 12c — Mobile responsive: tables → stacked cards ───── */
@media (max-width: 768px) {
    /* Convert any table marked .responsive-cards to a stacked list of mini-cards */
    .table.responsive-cards thead { display: none; }
    .table.responsive-cards, .table.responsive-cards tbody, .table.responsive-cards tr, .table.responsive-cards td {
        display: block;
        width: 100%;
    }
    .table.responsive-cards tr {
        background: white;
        border: 1px solid var(--brand-slate-200);
        border-radius: 12px;
        margin-bottom: 0.75rem;
        padding: 0.5rem;
        box-shadow: var(--shadow-sm);
    }
    .table.responsive-cards td {
        border: 0 !important;
        padding: 0.35rem 0.5rem;
        text-align: start;
    }
    .table.responsive-cards td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 90px;
        font-weight: 600;
        color: var(--brand-slate-600);
        font-size: 0.8rem;
        margin-inline-end: 0.4rem;
    }
    .table.responsive-cards td:first-child::before { display: none; }
    .table.responsive-cards td:first-child {
        font-size: 1.05rem;
        font-weight: 600;
        border-bottom: 1px solid var(--brand-slate-100) !important;
        margin-bottom: 0.35rem;
        padding-bottom: 0.5rem;
    }

    /* Bigger touch targets for mobile */
    .btn { min-height: 38px; }
    .form-control, .form-select { min-height: 40px; }

    /* Page header stacks on small screens */
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .page-header > * { width: 100%; }

    /* Quick-edit pencil always visible on mobile (no hover) */
    .quick-edit-btn { opacity: 1; }
}
